Skip to content
Snippets Groups Projects
Commit 63f38d05 authored by Petr Karpov's avatar Petr Karpov
Browse files

initialization commit

parent 2dcaa4a2
No related branches found
No related tags found
No related merge requests found
File added
module purge
module load anaconda/2/2019.03
module load intel/21.2.0
module load impi/2021.2
module load mkl/2021.2
#module load cuda/11.2
#MPIRUN_COMMDAND=mpirun
#unset I_MPI_HYDRA_BOOTSTRAP I_MPI_PMI_LIBRARY
MPIRUN_COMMDAND="srun -n 1 -p interactive --time=1:00 --mem=1G"
INSTALL_SUBDIR=install_mkl_blas_pathched_pdgemm_env_pilaenv
INSTALL_DIR=$HOME/soft/ScaLAPACK/$INSTALL_SUBDIR
MPI_DIR=`which mpicc`
echo MPI_DIR=$MPI_DIR
#--blaslib=$MKLROOT/lib/intel64/
# ${MKLROOT}/lib/intel64/libmkl_blas95_lp64.a ${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a -L${MKLROOT}/lib/intel64 -lpthread -lm -ldl
#python2 setup.py --prefix=/u/pekarp/soft/ScaLAPACK/install_all --mpibindir=$MPI_DIR --mpicc=mpiicc --mpif90=mpiifort --downall --ldflags_fc=-nofor-main
CFLAGS="-I${MKLROOT}/include"
FCFLAGS="-I${MKLROOT}/include/intel64/lp64 -I${MKLROOT}/include"
LDFLAGS_C="-L$MKL_HOME/lib/intel64 -Wl,-rpath,$MKL_HOME/lib/intel64"
LDFLAGS_FC="-nofor-main -L${MKLROOT}/lib/intel64 -Wl,-rpath,$MKL_HOME/lib/intel64"
#-I${MKLROOT}/include/intel64/lp64
python2 setup.py --prefix="$INSTALL_DIR" --mpibindir=$MPI_DIR --mpirun="$MPIRUN_COMMDAND" --mpicc=mpiicc --mpif90=mpiifort --ccflags="$CFLAGS" --fcflags="$FCFLAGS" --ldflags_c="$LDFLAGS_C" --ldflags_fc="$LDFLAGS_FC" --lapacklib="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl" |& tee -a setup_py_log_$INSTALL_SUBDIR.txt
#--lapacklib="$MKLROOT/lib/intel64/libmkl_lapack95_lp64.a"
cp build/download/scalapack.tgz $INSTALL_DIR
#! /usr/bin/env python
# -*- coding: utf-8 -*-
class Config:
# set default values
# PLASMA
blaslib = "" # the BLAS library
cblaslib = "" # the CBLAS library
lapacklib = "" # the Lapack library
lapclib = "" # the Lapack C interface
lapackinc = "" # the Lapack headers
cc = "cc" # the C compiler for plasma
fc = "gfortran" # the Fortran compiler for core_lapack
ranlib = "" # Ranlib
arflags = "rc" # ar flags
ldflags_c = "" # loader flags when main program is in C
ldflags_fc = "" # loader flags when main program is in Fortran
ccflags = "-O2"
fcflags = "-O2"
noopt = "-O0"
# ScaLAPACK
mpibindir = '' # directory containing mpicc and mpif77
mpiincdir = '' # directory containing mpi.h
mpicc, mpif90 = ['', ''] # the mpicc and mpif77 commands
mpirun = '' # the command for running mpi programs
scalapacklib = '' # scalapack library
def __init__(self, version):
self.version = version
File added
all = ["framework", "blas", "netlib"]
File added
#! /usr/bin/env python
# -*- coding: utf-8 -*-
###
#
# @file blas.py
#
# netlib is a software package provided by Univ. of Tennessee,
# Univ. of California Berkeley and Univ. of Colorado Denver
#
# @version 2.3.1
# @author Julie Langou
# @author Mathieu Faverge
# @date 2010-11-15
#
###
from utils import writefile, runShellCommand, killfiles, downloader, getURLName
import sys
import os
import shutil
class Blas:
blasurl = "http://netlib.org/blas/blas.tgz"
""" This class takes care of the BLAS installation. """
def __init__(self, config, netlib):
print "\n","="*40
print " BLAS installation/verification"
print "="*40
self.config = config
self.downcmd = netlib.downcmd
self.prefix = netlib.prefix
downblas = netlib.downblas;
# Checking if the LAPACK provided contains BLAS
# If this is the case we need to switch the linking order to make sure we take the user BLAS
if config.lapacklib:
sauveblaslib=self.config.blaslib
self.config.blaslib=self.config.lapacklib
print "Checking if the provided LAPACK ("+self.config.lapacklib+") contains BLAS"
if self.check_blas()==0:
self.config.BLAS_in_LAPACK="yes"
if sauveblaslib!="" or downblas>0:
if downblas > 1 :
blaslib_requested="Download Reference BLAS"
else:
blaslib_requested=sauveblaslib
print """Which BLAS library do you want to use ?
- b : the BLAS library you requested: """+blaslib_requested+"""
- l : the LAPACK library you provided: """+self.config.lapacklib
answer = raw_input(">[l] ")
if answer == "b":
self.config.blaslib=sauveblaslib
else:
self.config.blaslib=self.config.lapacklib
print "Using the BLAS library contained in LAPACK library "+self.config.lapacklib
self.config.blaslib=""
return;
else:
print "Using the BLAS library contained in LAPACK library "+self.config.lapacklib
self.config.blaslib=""
return;
else:
self.config.BLAS_in_LAPACK="no"
self.config.blaslib=sauveblaslib
if config.blaslib:
self.check_blas()
else:
if downblas==1:
print "We will take the Reference BLAS provided by the Reference LAPACK library"
elif downblas==2:
self.down_install_blas()
else:
print """
Please provide a working BLAS library. If a BLAS library
is not present on the system, the reference BLAS library it can be
automatically downloaded and installed by adding the --downblas flag.
Be aware that a reference BLAS library will be installed with the --downblas
flag so don't expect good performance.
You can specify the optimized BLAS library **installed** on your machine using the --blaslib option
For instance
--blaslib="-lessl" for IBM BLAS,
--blaslib="-framework veclib" for Mac OS/X,
--blaslib="-lgoto" for GOTO BLAS
--blaslib="-lf77blas -lcblas -latlas" for ATLAS
--blaslib="-lmkl_em64t -lguide" for MKL on emt64 architecture (remember to set environment variable MKL_NUM_THREADS=1)
--blaslib="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core" for single threaded MKL on 64-bit architectures using Intel compilers
--blaslib="-lmkl_intel -lmkl_sequential -lmkl_core" for single threaded MKL on 32-bit architectures using Intel compilers
--blaslib="-lmkl_gf -lmkl_sequential -lmkl_core" for single threaded MKL on 32-bit architectures using GNU Fortran compilers
etc...
.'
The BLAS library is not needed in the case where testing is disabled
by means of the --notesting flag.
"""
sys.exit()
def check_blas(self):
print "BLAS library is set to "+self.config.blaslib
print "Checking if provided BLAS works...",
# This function simply generates a FORTRAN program
# that contains few calls to BLAS routine and then
# checks if compilation, linking and execution are succesful
sys.stdout.flush()
writefile('tmpf.f',"""
program ftest
double precision da, dx(1)
dx(1)=1
da = 2
call dscal(1,da,dx,1)
stop
end\n""")
fcomm = self.config.fc+' -o tmpf '+'tmpf.f '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
(output, error, retz) = runShellCommand(fcomm)
if(retz != 0):
print '\n\nBLAS: provided BLAS cannot be used! aborting...'
print 'error is:\n','*'*40,'\n',fcomm,'\n',error,'\n','*'*40
sys.exit()
comm = './tmpf'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
print '\n\nBLAS: provided BLAS cannot be used! aborting...'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
killfiles(['tmpf.f','tmpf'])
print 'yes'
return 0;
def down_install_blas(self):
print """The reference BLAS library is being installed.
Don't expect high performance from this reference library!
If you want performance, you need to use an optimized BLAS library and,
to avoid unnecessary complications, if you need to compile this optimized BLAS
library, use the same compiler you're using here."""
sys.stdout.flush()
savecwd = os.getcwd()
# creating the build,lib and log dirs if don't exist
if not os.path.isdir(os.path.join(self.prefix,'lib')):
os.mkdir(os.path.join(self.prefix,'lib'))
if not os.path.isdir(os.path.join(os.getcwd(),'log')):
os.mkdir(os.path.join(os.getcwd(),'log'))
# Check if blas.tgz is already present in the working dir
# otherwise download it
if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.blasurl))):
print "Downloading reference BLAS...",
downloader(self.blasurl,self.downcmd)
print "done"
# unzip and untar
print 'Unzip and untar reference BLAS...',
comm = 'gunzip -f blas.tgz'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nBLAS: cannot unzip blas.tgz'
print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
comm = 'tar xf blas.tar'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nBLAS: cannot untar blas.tgz'
print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
os.remove('blas.tar')
print 'done'
# change to BLAS dir
os.chdir(os.path.join(os.getcwd(),'BLAS'))
# compile and generate library
print 'Compile and generate reference BLAS...',
sys.stdout.flush()
comm = self.config.fc+' '+self.config.fcflags+" -c *.f"
(output, error, retz) = runShellCommand(comm)
if retz:
print "\n\nBLAS: cannot compile blas"
print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
sys.exit()
log = output+error
comm = "ar cr librefblas.a *.o"
(output, error, retz) = runShellCommand(comm)
if retz:
print "\n\nBLAS: cannot create blas library"
print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
sys.exit()
log = log+output+error
comm = self.config.ranlib+' librefblas.a'
(output, error, retz) = runShellCommand(comm)
if retz:
print "\n\nBLAS: problem with ranlib"
print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
sys.exit()
print "done"
# write the log on a file
log = log+output+error
fulllog = os.path.join(savecwd,'log/blaslog')
writefile(fulllog, log)
print 'Installation of reference BLAS successful.'
print '(log is in ',fulllog,')'
# move librefblas.a to the lib directory
shutil.copy('librefblas.a',os.path.join(self.prefix,'lib/librefblas.a'))
# set framework variables to point to the freshly installed BLAS library
self.config.blaslib = '-L'+os.path.join(self.prefix,'lib')+' -lrefblas '
os.chdir(savecwd)
File added
This diff is collapsed.
File added
#! /usr/bin/env python
# -*- coding: utf-8 -*-
###
#
# @file lapack.py
#
# LAPACK is a software package provided by Univ. of Tennessee,
# Univ. of California Berkeley and Univ. of Colorado Denver
#
# @version 2.3.1
# @author Julie Langou
# @author Mathieu Faverge
# @date 2010-11-15
#
###
from utils import writefile, runShellCommand, killfiles, downloader, getURLName
import sys
import os
import shutil
import framework
class Lapack(framework.Framework):
lapackurl = "http://www.netlib.org/lapack/lapack.tgz"
""" This class takes care of the LAPACK installation. """
def __init__(self, config, netlib):
print "\n","="*40
print " Lapack installation/verification"
print "="*40
self.config = config
self.downblas = netlib.downblas;
self.downlapack = netlib.downlapack
self.downcmd = netlib.downcmd
self.prefix = netlib.prefix
self.netlib = netlib
if self.downblas==1:
self.config.blaslib=os.path.join(self.prefix,'lib/librefblas.a')
if self.downlapack == 2:
self.down_install_lapack()
ret = self.check_lapack()
if ret != 0:
if self.downlapack == 1:
self.down_install_lapack()
else:
print """
Please provide a working LAPACK library. If a LAPACK library is not
present on the system, the netlib LAPACK library can be automatically
downloaded and installed by adding the --downlapack flag.
Most used BLAS implementations already include the LAPACK library as
MKL, ACML, Goto, Goto2 or ATLAS. If you want to use one of these
libraries, you just have to specify correctly the --blaslib option or
you can specify where is located your own LAPACK library by using the
--lapacklib option.
With LAPACK, netlib require also the tmglib from LAPACK which is only
included in MKL and netlib LAPACK (--lapacklib=-ltmg -llapack). For
other BLAS libraries, LAPACK will be automatically downloaded from
netlib.
The LAPACK library is not needed in the case where testing is disabled
by means of the --notesting flag.
What do you want to do ?
- d : download the netlib LAPACK
- q : quit and try with another BLAS library or define the
lapacklib parameter.
"""
answer = raw_input(">[q] ")
if answer == "d":
self.down_install_lapack()
else:
sys.exit()
def check_lapack(self):
if (self.config.lapacklib == ""):
print "LAPACK library is set to "+self.config.blaslib
else:
print "LAPACK library is "+self.config.lapacklib
print "Checking if provided LAPACK works...",
# This function simply generates a Fortran program
# that contains few calls to LAPACK routine and then
# checks if compilation, linking and execution are succesful
sys.stdout.flush()
writefile('tmpf.f',"""
program ftest
integer N
parameter (N = 1)
double precision A(N, N), B(N)
integer I(N)
integer INFO
B(:) = 1
A(:,:) = 2
I(:) = 0
call cheevd( 'N', 'U', N, A, N, B, B, -1,
$ B, -1, I, -1, INFO)
stop
end\n""")
ldflg = self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
(output, error, retz) = runShellCommand(ccomm)
if(retz != 0):
if self.netlib.verbose:
print '\n\nLAPACK: provided LAPACK cannot be used! aborting...'
print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
else:
print "no"
return -1;
comm = './tmpf'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
if self.netlib.verbose:
print '\n\nLAPACK: provided LAPACK cannot be used! aborting...'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
else:
print "no"
return -1;
killfiles(['tmpf.f','tmpf'])
print 'yes'
print "Getting LAPACK version number...",
# This function simply calls LAPACK ilaver routine and then
# checks if compilation, linking and execution are succesful
sys.stdout.flush()
writefile('tmpf.f',"""
PROGRAM LAPACK_VERSION
*
INTEGER MAJOR, MINOR, PATCH
*
CALL ILAVER ( MAJOR, MINOR, PATCH )
WRITE(*, FMT = 9999 ) MAJOR, MINOR, PATCH
*
9999 FORMAT(I1,'.',I1,'.',I1)
END\n""")
ldflg = self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
(output, error, retz) = runShellCommand(ccomm)
if(retz != 0):
if self.netlib.verbose:
print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
killfiles(['tmpf.f'])
else:
comm = './tmpf'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
print 'cannot get LAPACK version number.'
if self.netlib.verbose:
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
else:
print output,
killfiles(['tmpf'])
print "Checking if provided LAPACK contains functions for test works...",
# This function simply generates a C program
# that contains few calls to LAPACK routine and then
# checks if compilation, linking and execution are succesful
sys.stdout.flush()
writefile('tmpf.f',"""
program ftest
double precision D(1), A(1:1), B(2)
integer ISEED( 4 )
integer INFO
B(1) = 1
do I = 1, 4
ISEED( I ) = 1
enddo
call dlarnv( 1, ISEED, 1, D )
call dlagsy( 1, 0, D, A, 1, ISEED, B, INFO )
stop
end\n""")
ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
(output, error, retz) = runShellCommand(ccomm)
if(retz != 0):
print 'no'
self.netlib.needtmg = 1
else:
comm = './tmpf'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
print 'no'
self.netlib.needtmg = 1;
else:
self.netlib.needtmg = 0;
print 'yes'
killfiles(['tmpf.f','tmpf'])
return 0;
def down_install_lapack(self):
print "The reference LAPACK library is being installed."
sys.stdout.flush()
savecwd = os.getcwd()
# creating the build,lib and log dirs if don't exist
if not os.path.isdir(os.path.join(self.prefix,'lib')):
os.mkdir(os.path.join(self.prefix,'lib'))
if not os.path.isdir(os.path.join(os.getcwd(),'log')):
os.mkdir(os.path.join(os.getcwd(),'log'))
# Check if lapack.tgz is already present in the working dir
# otherwise download it
if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.lapackurl))):
print "Downloading reference LAPACK...",
downloader(self.lapackurl,self.downcmd)
print "done"
# unzip and untar
print 'Unzip and untar reference LAPACK...',
comm = 'gunzip -f lapack.tgz'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nLAPACK: cannot unzip lapack.tgz'
print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
comm = 'tar xf lapack.tar'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nLAPACK: cannot untar lapack.tgz'
print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
os.remove('lapack.tar')
print 'done'
# # Overwrite [sd]lamch.f
# shutil.copy(os.path.join(self.netlib.installerdir,'src/dlamch.f'),
# os.path.join(os.getcwd(),'lapack-3.3.0/INSTALL'))
# shutil.copy(os.path.join(self.netlib.installerdir,'src/slamch.f'),
# os.path.join(os.getcwd(),'lapack-3.3.0/INSTALL'))
# change to LAPACK dir
os.chdir(os.path.join(os.getcwd(),'lapack-3.10.0'))
# Write Makefile.in
writefile('make.inc', """
# -*- Makefile -*-
####################################################################
# LAPACK make include file. #
# LAPACK, Version 3.3.0 #
# April 2009 #
####################################################################
#
# See the INSTALL/ directory for more examples.
#
SHELL = /bin/sh
#
# The machine (platform) identifier to append to the library names
#
PLAT = _LINUX
#
# Modify the FORTRAN and OPTS definitions to refer to the
# compiler and desired compiler options for your machine. NOOPT
# refers to the compiler options desired when NO OPTIMIZATION is
# selected. Define LOADER and LOADOPTS to refer to the loader
# and desired load options for your machine.
#
FORTRAN = """+self.config.fc+"""
OPTS = """+self.config.fcflags+"""
DRVOPTS = $(OPTS)
NOOPT = """+self.config.noopt+"""
LOADER = """+self.config.fc+"""
LOADOPTS = """+self.config.ldflags_fc+"""
#
# Timer for the SECOND and DSECND routines
#
# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
# TIMER = EXT_ETIME
# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
# TIMER = EXT_ETIME_
# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
# TIMER = INT_ETIME
# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
# SECOND and DSECND will use a call to the Fortran standard INTERNAL FUNCTION CPU_TIME
TIMER = INT_CPU_TIME
# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
# TIMER = NONE
#
# The archiver and the flag(s) to use when building archive (library)
# If you system has no ranlib, set RANLIB = echo.
#
ARCH = ar
ARCHFLAGS= """+self.config.arflags+"""
RANLIB = """+self.config.ranlib+"""
#
# The location of BLAS library for linking the testing programs.
# The target's machine-specific, optimized BLAS library should be
# used whenever possible.
#
BLASLIB = """+self.config.blaslib+"""
#
# Location of the extended-precision BLAS (XBLAS) Fortran library
# used for building and testing extended-precision routines. The
# relevant routines will be compiled and XBLAS will be linked only if
# USEXBLAS is defined.
#
# USEXBLAS = Yes
XBLASLIB =
# XBLASLIB = -lxblas
#
# Names of generated libraries.
#
LAPACKLIB = libreflapack.a
TMGLIB = libtmg.a
EIGSRCLIB = libeigsrc.a
LINSRCLIB = liblinsrc.a
""")
log = " ******* LOG LAPACK *******"
# compile and generate Reference BLAS library
if self.downblas==1:
print 'Compile and generate Reference BLAS...',
sys.stdout.flush()
comm = self.make+' blaslib'
(output, error, retz) = runShellCommand(comm)
if retz:
print "\n\nLAPACK: cannot compile Reference BLAS"
print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
sys.exit()
log += output+error
self.config.blaslib = '-L'+os.path.join(self.prefix,'lib')+' -lrefblas'
print 'done'
# compile and generate LAPACK library
print 'Compile and generate LAPACK...',
sys.stdout.flush()
comm = self.make+' lapacklib tmglib'
(output, error, retz) = runShellCommand(comm)
if retz:
print "\n\nLAPACK: cannot compile LAPACK"
print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
sys.exit()
log += output+error
print 'done'
# write the log on a file
fulllog = os.path.join(savecwd,'log/lapacklog')
writefile(fulllog, log)
print 'Installation of libreflapack.a successful.'
print '(log is in ',fulllog,')'
# move lib to the lib directory
shutil.copy('libreflapack.a',os.path.join(self.prefix,'lib/libreflapack.a'))
shutil.copy('libtmg.a',os.path.join(self.prefix,'lib/libtmg.a'))
# set framework variables to point to the freshly installed LAPACK library
self.config.lapacklib = '-L'+os.path.join(self.prefix,'lib')+' -ltmg -lreflapack'
if(self.netlib.testing == 1):
print 'Compiling and Running LAPACK test suite (this will take several minutes)...',
sys.stdout.flush()
comm = self.make+' lapack_testing'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
print '\n\nLAPACK: error running LAPACK TESTING SUITE'
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
sys.exit()
log = output+error
fulllog = os.path.join(savecwd,'log/lapack_testing')
writefile(fulllog, log)
print 'done'
print '(log is in ',fulllog,')'
os.chdir(savecwd)
# Check if the installation is successful
self.netlib.verbose = 1
ret = self.check_lapack()
self.netlib.verbose = 0
if ret != 0:
sys.exit()
File added
#!/usr/bin/python
# -----------------------------------------
# ScaLAPACK installer
# University of Tennessee Knoxville
# October 16, 2007
# ----------------------------------------
from utils import writefile, runShellCommand, killfiles, downloader, getURLName
import sys
import os
import framework
import shutil
class Scalapack(framework.Framework):
""" This class takes care of the ScaLAPACK installation. """
def __init__(self, argv, config):
framework.Framework.__init__(self, argv, config)
def resume(self):
print '\n','='*40
print 'ScaLAPACK installer is starting now. Buckle up!'
print '='*40
self.down_install()
framework.Framework.resume(self)
def write_slmakeinc(self):
""" Writes the SLmake.inc file for ScaLAPACK installation """
sdir = os.getcwd()
print 'Writing SLmake.inc...',
sys.stdout.flush()
writefile('SLmake.inc',"""
#
# C preprocessor definitions: set CDEFS to one of the following:
#
# -DNoChange (fortran subprogram names are lower case without any suffix)
# -DUpCase (fortran subprogram names are upper case without any suffix)
# -DAdd_ (fortran subprogram names are lower case with "_" appended)
CDEFS = """+self.mangling+"""
#
# The fortran and C compilers, loaders, and their flags
#
FC = """+self.config.mpif90+"""
CC = """+self.config.mpicc+"""
NOOPT = """+self.config.noopt+"""
FCFLAGS = """+self.config.fcflags+"""
CCFLAGS = """+self.config.ccflags+"""
SRCFLAG =
FCLOADER = $(FC)
CCLOADER = $(CC)
FCLOADFLAGS = """+self.config.ldflags_fc+"""
CCLOADFLAGS = """+self.config.ldflags_c+"""
#
# The archiver and the flag(s) to use when building archive (library)
# Also the ranlib routine. If your system has no ranlib, set RANLIB = echo
#
ARCH = ar
ARCHFLAGS = cr
RANLIB = """+self.config.ranlib+"""
#
# The name of the ScaLAPACK library to be created
#
SCALAPACKLIB = libscalapack.a
#
# BLAS, LAPACK (and possibly other) libraries needed for linking test programs
#
BLASLIB = """+self.config.blaslib+"""
LAPACKLIB = """+self.config.lapacklib+"""
LIBS = $(LAPACKLIB) $(BLASLIB)
""")
self.scalapackdir = sdir
print 'done.'
def down_install(self):
""" Download ind install ScaLAPACK """
savecwd = os.getcwd()
# creating the build and lib dirs if don't exist
if not os.path.isdir(os.path.join(self.prefix,'lib')):
os.mkdir(os.path.join(self.prefix,'lib'))
if not os.path.isdir(os.path.join(self.prefix,'include')):
os.mkdir(os.path.join(self.prefix,'include'))
if not os.path.isdir(os.path.join(os.getcwd(),'log')):
os.mkdir(os.path.join(os.getcwd(),'log'))
if(not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.scalapackurl)))):
print "Downloading ScaLAPACK...",
downloader(self.scalapackurl, self.downcmd)
print "done"
comm = 'gunzip -f scalapack.tgz'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nScaLAPACK: cannot unzip scalapack.tgz'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
comm = 'tar xf scalapack.tar'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nScaLAPACK: cannot untar scalapack.tar'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
sys.exit()
os.remove('scalapack.tar')
# change to ScaLAPACK dir
# os.chdir(os.path.join(os.getcwd(),'scalapack-2.0.0'))
comm = 'ls -1 | grep scalapack'
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nScaLAPACK: error changing to ScaLAPACK dir'
print 'stderr:\n','*'*40,'\n',' -> no ScaLAPACK directory found','\n','*'*40
sys.exit()
rep_name = output.replace ("\n","")
print 'Installing ',rep_name,'...'
rep_name = os.path.join(os.getcwd(),rep_name)
os.chdir(rep_name)
self.write_slmakeinc()
print 'Compiling BLACS, PBLAS and ScaLAPACK...',
sys.stdout.flush()
comm = self.make+" lib"
(output, error, retz) = runShellCommand(comm)
if retz:
print '\n\nScaLAPACK: error building ScaLAPACK'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
writefile(os.path.join(savecwd,'log/scalog'), output+error)
sys.exit()
fulllog = os.path.join(savecwd,'log/scalog')
writefile(fulllog, output+error)
print 'done'
# move lib to the lib directory
shutil.copy('libscalapack.a',os.path.join(self.prefix,'lib/libscalapack.a'))
self.config.scalapacklib = '-L'+os.path.join(self.prefix,'lib')+' -lscalapack'
print "Getting ScaLAPACK version number...",
# This function simply calls ScaLAPACK pilaver routine and then
# checks if compilation, linking and execution are succesful
sys.stdout.flush()
writefile('tmpf.f',"""
PROGRAM ScaLAPACK_VERSION
*
INTEGER MAJOR, MINOR, PATCH
*
CALL PILAVER ( MAJOR, MINOR, PATCH )
WRITE(*, FMT = 9999 ) MAJOR, MINOR, PATCH
*
9999 FORMAT(I1,'.',I1,'.',I1)
END\n""")
ldflg = self.config.scalapacklib+' '+self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' -lm'
ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
(output, error, retz) = runShellCommand(ccomm)
if(retz != 0):
print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
else:
comm = './tmpf'
(output, error, retz) = runShellCommand(comm)
if(retz != 0):
print 'cannot get ScaLAPACK version number.'
print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
else:
print output,
killfiles(['tmpf'])
print 'Installation of ScaLAPACK successful.'
print '(log is in ',fulllog,')'
if self.testing == 1:
filename=os.path.join(savecwd,'log/sca_testing')
myfile = open(filename, 'w')
print 'Compiling test routines...',
sys.stdout.flush()
comm = self.make+' exe'
(output, error, retz) = runShellCommand(comm)
myfile.write(output+error)
if(retz != 0):
print '\n\nScaLAPACK: error building ScaLAPACK test routines'
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
writefile(os.path.join(savecwd,'log/scalog'), output+error)
sys.exit()
print 'done'
# TESTING
print 'Running BLACS test routines...',
sys.stdout.flush()
os.chdir(os.path.join(os.getcwd(),'BLACS/TESTING'))
a = ['xCbtest', 'xFbtest']
for testing_exe in a:
myfile.write('\n ************************************************* \n')
myfile.write(' *** OUTPUT BLACS TESTING '+testing_exe+' *** \n')
myfile.write(' ************************************************* \n')
comm = self.config.mpirun+' -np 4 ./'+testing_exe
(output, error, retz) = runShellCommand(comm)
myfile.write(output+error)
if(retz != 0):
# This is normal to exit in Error for the BLACS TESTING (good behaviour)
# So we are going to check that the output have the last line of the testing : DONE BLACS_GRIDEXIT
if output.find('DONE BLACS_GRIDEXIT')==-1:
print '\n\nBLACS: error running BLACS test routines '+testing_exe
print '\n\nBLACS: Command '+comm
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
myfile.close()
sys.exit()
os.chdir(os.path.join(os.getcwd(),'../..'))
print 'done'
print 'Running PBLAS test routines...',
sys.stdout.flush()
os.chdir(os.path.join(os.getcwd(),'PBLAS/TESTING'))
a = ['xcpblas1tst', 'xdpblas1tst', 'xspblas1tst', 'xzpblas1tst']
a.extend(['xcpblas2tst', 'xdpblas2tst', 'xspblas2tst', 'xzpblas2tst'])
a.extend(['xcpblas3tst', 'xdpblas3tst', 'xspblas3tst', 'xzpblas3tst'])
for testing_exe in a:
myfile.write('\n ************************************************* \n')
myfile.write(' *** OUTPUT PBLAS TESTING '+testing_exe+' *** \n')
myfile.write(' ************************************************* \n')
comm = self.config.mpirun+' -np 4 ./'+testing_exe
(output, error, retz) = runShellCommand(comm)
myfile.write(output+error)
if(retz != 0):
print '\n\nPBLAS: error running PBLAS test routines '+testing_exe
print '\n\nPBLAS: Command '+comm
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
myfile.close()
sys.exit()
os.chdir(os.path.join(os.getcwd(),'../..'))
print 'done'
print 'Running REDIST test routines...',
sys.stdout.flush()
os.chdir(os.path.join(os.getcwd(),'REDIST/TESTING'))
a = ['xcgemr','xctrmr','xdgemr','xdtrmr','xigemr','xitrmr','xsgemr','xstrmr','xzgemr','xztrmr']
for testing_exe in a:
myfile.write('\n ************************************************* \n')
myfile.write(' *** OUTPUT REDIST TESTING '+testing_exe+' *** \n')
myfile.write(' ************************************************* \n')
comm = self.config.mpirun+' -np 4 ./'+testing_exe
(output, error, retz) = runShellCommand(comm)
myfile.write(output+error)
if(retz != 0):
print '\n\nREDIST: error running REDIST test routines '+testing_exe
print '\n\nREDIST: Command '+comm
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
myfile.close()
sys.exit()
os.chdir(os.path.join(os.getcwd(),'../..'))
print 'done'
print 'Running (some) ScaLAPACK test routines...',
sys.stdout.flush()
os.chdir(os.path.join(os.getcwd(),'TESTING'))
a = ['xslu', 'xdlu', 'xclu', 'xzlu']
a.extend(['xsqr', 'xdqr', 'xcqr', 'xzqr'])
a.extend(['xsinv', 'xdinv', 'xcinv', 'xzinv'])
a.extend(['xsllt', 'xdllt', 'xcllt', 'xzllt'])
a.extend(['xshrd', 'xdhrd', 'xchrd', 'xzhrd'])
a.extend(['xsls', 'xdls', 'xcls', 'xzls'])
a.extend(['xssyevr', 'xdsyevr', 'xcheevr', 'xzheevr'])
a.extend(['xshseqr', 'xdhseqr'])
for testing_exe in a:
myfile.write('\n ************************************************* \n')
myfile.write(' *** OUTPUT ScaLAPACK TESTING '+testing_exe+' *** \n')
myfile.write(' ************************************************* \n')
comm = self.config.mpirun+' -np 4 ./'+testing_exe
(output, error, retz) = runShellCommand(comm)
myfile.write(output+error)
if(retz != 0):
print '\n\nScaLAPACK: error running ScaLAPACK test routines '+testing_exe
print '\n\nScaLAPACK: Command '+comm
print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
myfile.close()
sys.exit()
os.chdir(os.path.join(os.getcwd(),'..'))
print 'done'
myfile.close()
os.chdir(savecwd)
print "ScaLAPACK is installed. Use it in moderation :-)"
File added
#! /usr/bin/env python
# -*- coding: utf-8 -*-
###
#
# @file utils.py
#
# netlib is a software package provided by Univ. of Tennessee,
# Univ. of California Berkeley and Univ. of Colorado Denver
#
# @version 2.3.1
# @author Julie Langou
# @author Mathieu Faverge
# @date 2010-11-15
#
###
import os
import re
import shutil
import popen2
import select
def writefile(fname, fill):
""" writes the file fname with content fill """
fp = open(fname,'w')
fp.write(fill)
fp.close()
def killfiles(lst):
""" deletes a list of files """
for i in lst:
if(os.path.isfile(i)):
os.remove(i)
def openPipe(command):
pipe = None
if hasattr(popen2, 'Popen3'):
pipe = popen2.Popen3(command, 1)
input = pipe.tochild
output = pipe.fromchild
err = pipe.childerr
else:
(input, output, err) = os.popen3(command)
return (input, output, err, pipe)
class NullFile:
def write(self, s): pass
def flush(self): pass
def runShellCommand(command, outfile=None):
""" runs a shell command """
ret = None
out = ''
err = ''
if not outfile:
outfile = NullFile()
(input, output, error, pipe) = openPipe(command)
input.close()
outputClosed = 0
errorClosed = 0
lst = [output, error]
while 1:
ready = select.select(lst, [], [])
if len(ready[0]):
if error in ready[0]:
msg = error.readline()
if msg:
err += msg
else:
errorClosed = 1
lst.remove(error)
if output in ready[0]:
msg = output.readline()
if msg:
out += msg
outfile.write(msg)
outfile.flush()
else:
outputClosed = 1
lst.remove(output)
if outputClosed and errorClosed:
break
output.close()
error.close()
if pipe:
ret = pipe.wait()
return (out, err, ret)
def getURLName(url):
directory=os.curdir
name="%s%s%s" % (
directory,
os.sep,
url.split("/")[-1]
)
return name
def downloader(uri,cmd):
""" downloads the content of an URL """
savedir = os.getcwd()
downdir = savedir+"/download"
if(not os.path.isdir(downdir)):
print"Creating directory", downdir
os.mkdir(downdir)
os.chdir(downdir)
name = getURLName(uri)
try:
if(os.path.isfile(downdir+"/"+name)):
print "(package "+name+" already downloaded)...",
elif(cmd == 'urllib2'):
import urllib2
url = urllib2.urlopen(uri)
f = open(name,'w')
for line in url.readlines():
f.write(line)
url.close()
f.close()
elif(cmd == 'wget'):
comm = 'wget '+uri
(output, error, retz) = runShellCommand(comm)
else:
raise
except:
print " "
print "================================================================================="
print "Cannot download"+name
print "Make sure the network is reachable."
print "Packages may be downloaded with wget though a proxy; in order to"
print "enable this feature it is enough the set the http_proxy environment"
print "variable (read the wget man pages for more details)."
print "If you still have troubles, you can manually download "+name+" from this URL:"
print uri
print "into the current directory:"
print os.getcwd()
os.chdir(savedir)
shutil.copy('download/'+name, './')
def fixpaths(inpath):
lst = inpath.split(" ")
outpath = ""
if ((len(lst) == 1) and (inpath[0] != "download") and (inpath[0] != '-')):
outpath = os.path.abspath(inpath)
return outpath
else:
for i in lst:
if re.search("^-L",i):
p = "-L"+os.path.abspath(i[2:])
else:
p = i
outpath = outpath+p+" "
return outpath
File added
setup.py 0 → 100755
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
#
# @file setup.py
###
# -----------------------------------------
# ScaLAPACK installer
# University of Tennessee Knoxville
# October 16, 2007
# ----------------------------------------
import sys
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_MICRO = 3
from script.blas import Blas
from script.lapack import Lapack
from script.scalapack import Scalapack
import netlib
def main(argv):
### Store history of executed commands in config.log
cmd = ""
for arg in argv:
cmd += arg+" "
cmd += "\n"
fp = open("history.log",'a')
fp.write(cmd)
fp.close()
### END
config = netlib.Config((VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO))
config.fc = "ifort"
scalapack = Scalapack(argv, config)
if (scalapack.testing!= 0):
Blas(config, scalapack);
Lapack(config, scalapack);
scalapack.resume()
return 0
if "__main__" == __name__:
sys.exit(main(sys.argv))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment