Esempio n. 1
0
 def crawl_daili66(self, page_count=4):
     start_url = "http://www.66ip.cn/{}.html"
     urls = [start_url.format(i) for i in range(1, page_count + 1)]
     for url in urls:
         print(f"crawling {url}")
         html = downloader(url)
         if html:
             doc = PyQuery(html)
             trs = doc('.containerbox table tr:gt(0)').items()
             for tr in trs:
                 ip = tr.find("td:nth-child(1)").text()
                 port = tr.find("td:nth-child(2)").text()
                 yield ":".join([ip, port])
Esempio n. 2
0
 def crawl_ip3366(self):
     for i in range(1, 4):
         start_url = 'http://www.ip3366.net/?stype=1&page={}'.format(i)
         html = downloader(start_url)
         if html:
             find_tr = re.compile('<tr>(.*?)</tr>', re.S)
             trs = find_tr.findall(html)
             for s in range(1, len(trs)):
                 find_ip = re.compile('<td>(\d+\.\d+\.\d+\.\d+)</td>')
                 re_ip_address = find_ip.findall(trs[s])
                 find_port = re.compile('<td>(\d+)</td>')
                 re_port = find_port.findall(trs[s])
                 for address, port in zip(re_ip_address, re_port):
                     address_port = address + ':' + port
                     yield address_port.replace(' ', '')
Esempio n. 3
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 = 'mkdir BLAS && tar x --strip-components=1 -C BLAS -f 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()
        print "done"

        log = log + output + error

        comm = self.config.ranlib + " librefblas.a"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create table of contents for blas library"
            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/libblas.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.blaslib = '-L' + os.path.join(self.prefix,
                                                  'lib') + ' -lblas '
        self.config.blasdir = self.prefix
        os.chdir(savecwd)
Esempio n. 4
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()
        print "done"

        log = log+output+error

        comm = self.config.ranlib+" librefblas.a"
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nBLAS: cannot create table of contents for blas library"
            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)
Esempio n. 5
0
    def down_install_cblas(self):

        print """
The reference CBLAS 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(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'))

        # Check if cblas.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(
                os.path.join(os.getcwd(), getURLName(self.cblasurl))):
            print "Downloading reference CBLAS...",
            downloader(self.cblasurl, self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference CBLAS...',
        comm = 'gunzip -f cblas.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot unzip cblas.tgz'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()

        comm = 'tar xf cblas.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot untar cblas.tgz'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()
        os.remove('cblas.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(), 'CBLAS'))

        # Write Makefile.in
        writefile(
            'Makefile.in', """
# Makefile.in (Bblas Installer)
#
#-----------------------------------------------------------------------------
# Shell
#-----------------------------------------------------------------------------
SHELL = /bin/sh

#-----------------------------------------------------------------------------
# Platform
#-----------------------------------------------------------------------------

PLAT = """ + self.plat + """

#-----------------------------------------------------------------------------
# Libraries and includs
#-----------------------------------------------------------------------------

BLLIB = """ + self.config.blaslib + """
CBDIR = """ + os.getcwd() + """
CBLIBDIR = $(CBDIR)/lib
CBLIB = $(CBLIBDIR)/libcblas.a

#-----------------------------------------------------------------------------
# Compilers
#-----------------------------------------------------------------------------

CC = """ + self.config.cc + """
FC = """ + self.config.fc + """
LOADER = $(FC)

#-----------------------------------------------------------------------------
# Flags for Compilers
#-----------------------------------------------------------------------------

CFLAGS = """ + self.config.ccflags + """ """ + self.mangling + """
FFLAGS = """ + self.config.fcflags + """

#-----------------------------------------------------------------------------
# Archive programs and flags
#-----------------------------------------------------------------------------

ARCH      = ar
ARCHFLAGS = """ + self.config.arflags + """
RANLIB    = """ + self.config.ranlib + """
""")

        # compile and generate library
        print 'Compile and generate reference CBLAS...',
        sys.stdout.flush()
        comm = self.make + ' alllib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nCBLAS: cannot compile cblas"
            print "stderr:\n", "*" * 40, "\n", comm, '\n', error, "\n", "*" * 40
            sys.exit()

        log = output + error

        # write the log on a file
        log = log + output + error
        fulllog = os.path.join(savecwd, 'log/cblaslog')
        writefile(fulllog, log)
        print 'Installation of reference CBLAS successful.'
        print '(log is in ', fulllog, ')'

        # move libcblas.a to the lib directory
        shutil.copy('lib/libcblas.a',
                    os.path.join(self.prefix, 'lib/libcblas.a'))

        # move cblas.h to the include directory
        shutil.copy('include/cblas.h',
                    os.path.join(self.prefix, 'include/cblas.h'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.cblasdir = self.prefix
        self.config.cblaslib = '-L' + os.path.join(self.prefix,
                                                   'lib') + ' -lcblas'
        os.chdir(savecwd)

        # Check if the installation is successful
        self.bblas.verbose = 1
        ret = self.check_cblas()
        self.bblas.verbose = 0
        if ret != 0:
            sys.exit()
Esempio n. 6
0
File: tmg.py Progetto: randyp/randyp
    def down_install_tmg(self):

        print """
The libtmg from 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 BLAS...',
        comm = 'gunzip -f lapack.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nlibtmg: 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\nlibtmg: cannot untar lapack.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()
        os.remove('lapack.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(),'lapack-3.3.1'))

        # Write Makefile.in
        writefile('make.inc', """
# -*- Makefile -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.3.1                                           #
#  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.cblaslib+"""
#
#  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    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
""")

        # compile and generate library
        print 'Compile and generate libtmg...',
        sys.stdout.flush()
        comm = self.make+' tmglib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nlintmg: cannot compile libtmg"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/tmglog')
        writefile(fulllog, log)
        print 'Installation of libtmg.a successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('libtmg.a',os.path.join(self.prefix,'lib/libtmg.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapacklib = '-L'+os.path.join(self.prefix,'lib')+' -ltmg '+self.config.lapacklib

        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1
        self.check_tmg()
        self.plasma.verbose = 0
Esempio n. 7
0
    def down_install_lapc(self):

        print """
The reference LAPACK C interface 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(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 self.config.lapinstalled == 0:
            # Check if lapacke.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 C interface...",
                downloader(self.lapackurl,self.downcmd)
                print "done"

            # unzip and untar
            print 'Unzip and untar reference LAPACK C interface...',
            comm = 'gunzip -f '+self.lapversion+'.tgz'
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print '\n\nLAPCWRAPPER: cannot unzip '+self.lapversion+'.tgz'
                print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
                sys.exit()

            comm = 'tar xf '+self.lapversion+'.tar'
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print '\n\nLAPCWRAPPER: cannot untar '+self.lapversion+'.tar'
                print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
                sys.exit()
            os.remove(self.lapversion+'.tar')
            print 'done'

            #Apply the patch to correct [sd]lantr
            print 'Apply patch on lapacke...',
            comm = '(cd '+self.lapversion+' && patch -p 0 < '+(os.path.join(savecwd,'../script/patch_lantr'))+')'
            (output, error, retz) = runShellCommand(comm)
            print 'done'
            
        # change to LAPACK C interface dir
        os.chdir(os.path.join(os.getcwd(), self.lapversion))

        # Write Makefile.in
        writefile('make.inc', """
# -*- Makefile generated by PLASMA installer -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.4.0                                           #
#  April 2012                                                      #
####################################################################
#
SHELL = /bin/sh
#
#  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+"""
MAKE     = make -j 8
#
# 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 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
#
#  Configuration LAPACKE: Native C interface to LAPACK
#  To generate LAPACKE library: type 'make lapackelib'
#  Configuration file: turned off (default)
#  Complex types: C99 (default)
#  Name pattern: mixed case (default)
#  (64-bit) Data model: LP64 (default)
#
# CC is the C compiler, normally invoked with options CFLAGS.
#
CC     = """+self.config.cc+"""
CFLAGS = """+self.config.ccflags+' '+self.mangling+"""
#
#  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    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
LAPACKELIB   = liblapacke.a
""")

        # compile and generate library
        print 'Compile and generate reference LAPACK C interface...',
        sys.stdout.flush()
        comm = self.make+' -j 4 lapackelib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nLAPCWRAPPER: cannot compile LAPACK C interface"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/lapackcwrapperlog')
        writefile(fulllog, log)
        print 'Installation of reference LAPACK C interface successful.'
        print '(log is in ',fulllog,')'

        # move liblapacke.a to the lib directory
        shutil.copy('liblapacke.a',os.path.join(self.prefix,'lib/liblapacke.a'))

        # move headers to the include directory
        shutil.copy('LAPACKE/include/lapacke.h', os.path.join(self.prefix,'include/lapacke.h'))
        shutil.copy('LAPACKE/include/lapacke_config.h', os.path.join(self.prefix,'include/lapacke_config.h'))
        shutil.copy('LAPACKE/include/lapacke_utils.h', os.path.join(self.prefix,'include/lapacke_utils.h'))
        shutil.copy('LAPACKE/include/lapacke_mangling.h', os.path.join(self.prefix,'include/lapacke_mangling.h'))
        shutil.copy('LAPACKE/include/lapacke_mangling_with_flags.h', os.path.join(self.prefix,'include/lapacke_mangling_with_flags.h'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapclib   = '-L'+os.path.join(self.prefix,'lib')+' -llapacke'
        self.config.lapackinc = '-I'+os.path.join(self.prefix,'include')
        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1
        ret = self.check_lapc()
        self.plasma.verbose = 0
        if ret != 0 :
            sys.exit()
Esempio n. 8
0
    def down_install_cblas(self):

        print """
The reference CBLAS 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(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'))

        # Check if cblas.tgz is already present in the working dir
        # otherwise download it
        if not os.path.isfile(os.path.join(os.getcwd(),getURLName(self.cblasurl))):
            print "Downloading reference CBLAS...",
            downloader(self.cblasurl,self.downcmd)
            print "done"

        # unzip and untar
        print 'Unzip and untar reference BLAS...',
        comm = 'gunzip -f cblas.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot unzip cblas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()

        comm = 'tar xf cblas.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCBLAS: cannot untar cblas.tgz'
            print 'stderr:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            sys.exit()
        os.remove('cblas.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(),'CBLAS'))

        # Write Makefile.in
        writefile('Makefile.in', """
# Makefile.in (Plasma Installer)
#
#-----------------------------------------------------------------------------
# Shell
#-----------------------------------------------------------------------------
SHELL = /bin/sh

#-----------------------------------------------------------------------------
# Platform
#-----------------------------------------------------------------------------

PLAT = """+self.plat+"""

#-----------------------------------------------------------------------------
# Libraries and includs
#-----------------------------------------------------------------------------

BLLIB = """+self.config.blaslib+"""
CBDIR = """+os.getcwd()+"""
CBLIBDIR = $(CBDIR)/lib
CBLIB = $(CBLIBDIR)/libcblas.a

#-----------------------------------------------------------------------------
# Compilers
#-----------------------------------------------------------------------------

CC = """+self.config.cc+"""
FC = """+self.config.fc+"""
LOADER = $(FC)

#-----------------------------------------------------------------------------
# Flags for Compilers
#-----------------------------------------------------------------------------

CFLAGS = """+self.config.ccflags+""" """+self.mangling+"""
FFLAGS = """+self.config.fcflags+"""

#-----------------------------------------------------------------------------
# Archive programs and flags
#-----------------------------------------------------------------------------

ARCH      = ar
ARCHFLAGS = """+self.config.arflags+"""
RANLIB    = """+self.config.ranlib+"""
""")

        # compile and generate library
        print 'Compile and generate reference CBLAS...',
        sys.stdout.flush()
        comm = self.make+' alllib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nCBLAS: cannot compile cblas"
            print "stderr:\n","*"*40,"\n",comm,'\n',error,"\n","*"*40
            sys.exit()

        log = output+error

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/cblaslog')
        writefile(fulllog, log)
        print 'Installation of reference CBLAS successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('lib/libcblas.a',os.path.join(self.prefix,'lib/libcblas.a'))

        # move cblas.h to the include directory
        shutil.copy('include/cblas.h',os.path.join(self.prefix,'include/cblas.h'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.cblaslib  = '-L'+os.path.join(self.prefix,'lib')+' -lcblas'
        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1;
        ret = self.check_cblas()
        self.plasma.verbose = 0;
        if ret != 0 :
            sys.exit()
Esempio n. 9
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 BLAS...',
        comm = 'tar -xvzf  lapack-3.4.1.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()

        print 'done'

#         # Overwrite [sd]lamch.f
#         shutil.copy(os.path.join(self.plasma.installerdir,'src/dlamch.f'),
#                     os.path.join(os.getcwd(),'lapack-3.3.1/INSTALL'))
#         shutil.copy(os.path.join(self.plasma.installerdir,'src/slamch.f'),
#                     os.path.join(os.getcwd(),'lapack-3.3.1/INSTALL'))

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(), 'lapack-3.4.1')) #self.lapversion))

        # Write Makefile.in
        writefile('make.inc', """
# -*- Makefile generated by PLASMA installer -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.4.0                                           #
#  April 2012                                                      #
####################################################################
#
SHELL = /bin/sh
#
#  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 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
#
#  Configuration LAPACKE: Native C interface to LAPACK
#  To generate LAPACKE library: type 'make lapackelib'
#  Configuration file: turned off (default)
#  Complex types: C99 (default)
#  Name pattern: mixed case (default)
#  (64-bit) Data model: LP64 (default)
#
# CC is the C compiler, normally invoked with options CFLAGS.
#
CC     = """+self.config.cc+"""
CFLAGS = """+self.config.ccflags+"""
#
#  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    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
LAPACKELIB   = liblapacke.a
""")

        # compile and generate 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

        # write the log on a file
        log = log+output+error
        fulllog = os.path.join(savecwd,'log/lapacklog')
        writefile(fulllog, log)
        print 'Installation of liblapack.a successful.'
        print '(log is in ',fulllog,')'

        # move libcblas.a to the lib directory
        shutil.copy('liblapack.a',os.path.join(self.prefix,'lib/liblapack.a'))
        shutil.copy('libtmg.a',os.path.join(self.prefix,'lib/libtmg.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapacklib  = '-L'+os.path.join(self.prefix,'lib')+' -ltmg -llapack'
        os.chdir(savecwd)

        self.config.lapinstalled = 1;

        # Check if the installation is successful
        self.plasma.verbose = 1
        ret = self.check_lapack()
        self.plasma.verbose = 0
        if ret != 0:
            sys.exit()
Esempio n. 10
0
SNAPS_MIN = 7  # The minimum number of snapshots to create a time-lapse

SHOW_IP = False  # Set "True" to show the IP in the post
############################################################

bot = telegram.Bot(token=BOT_TOKEN)

while True:
    ip = ''
    country = ''
    city = ''
    res_count = 0
    print('Looking for a random city...')
    while res_count == 0:
        city = utils.randomizer()
        res_count = utils.downloader(city)
        if res_count > 0:
            print(f'{city} selected.')
            print(f'{res_count} results retrieved from JSON')

    # GIFs are stored in the local "snapshots" directory
    try:
        os.makedirs('snapshots/tmp')
    except OSError:
        pass

    # Setup the Shodan API object
    api = shodan.Shodan(SHODAN_API_KEY)
    # Show a progress indicator
    BAR_FORMAT = '{desc}{percentage:3.0f}%[{bar}] {n_fmt}/{total_fmt} '
    '[{elapsed}<{remaining}, {rate_fmt}{postfix}]'
Esempio n. 11
0
File: plasma.py Progetto: pjzuk/GRPY
    def down_install(self):
        """ Download and install PLASMA """

        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'))

        versions = self.versions

        for ver in versions:
            cur_fname = "plasma_" + ver + ".tar.gz"

            if not os.path.isfile(os.path.join(os.getcwd(), cur_fname)):
                cur_url = self.urlbase + "/" + cur_fname
                print 'Downloading PLASMA from', cur_url
                downloader(cur_url, self.downcmd)
            else:
                print 'Already downloaded PLASMA to', cur_fname

            if os.path.isfile(os.path.join(os.getcwd(), cur_fname)):
                self.version = ver
                break

        comm = "gunzip -f " + cur_fname
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nPLASMA: cannot unzip " + cur_fname
            print "stderr:\n", '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        cur_tar = cur_fname[:-3]
        comm = "tar xf " + cur_tar
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nPLASMA: cannot untar " + cur_tar
            print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()
        os.remove(cur_tar)

        # os.chdir(os.path.join(os.getcwd(),'plasma'))
        comm = 'ls -1 | grep plasma_ | grep -v tar | head -n 1'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\PLASMA: error changing to PLASMA dir'
            print 'stderr:\n', '*' * 40, '\n', '   ->  no plasma 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_makeinc()

        print 'Compiling PLASMA...',
        sys.stdout.flush()
        comm = self.make + ' lib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nPLASMA: error building PLASMA'
            print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
            writefile(os.path.join(savecwd, 'log/plasmalog'), output + error)
            sys.exit()

        liblog = os.path.join(savecwd, 'log/plasmalog')
        writefile(liblog, output + error)
        print 'Installation of PLASMA successful.'
        print '(log is in ', liblog, ')'

        # Testings
        if self.testing == 1:

            # Open the file for writing the output and errors
            testlog = os.path.join(savecwd, 'log/plasmatestlog')
            f = open(testlog, 'w')

            # Compiling tests
            print 'Compiling tests...',
            sys.stdout.flush()
            comm = self.make + ' test'
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print '\n\nPLASMA: error building PLASMA test routines'
                print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                f.write(output + error)
                f.close()
                sys.exit()
            print 'done'
            f.write(output + error)

            # Running in
            os.chdir(os.path.join(os.getcwd(), 'testing'))
            print 'Running PLASMA tests on', self.nbcores, 'cores...(takes some time, feel free to grab a coffee!)'
            print '--> testing ...',
            sys.stdout.flush()
            comm = './plasma_testing.py -c ' + str(self.nbcores)
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\n\nPLASMA: Testing failed... '
                print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                f.write(output + error)
                f.close()
                sys.exit()
            print 'done'
            print error
            f.write(output + error)

            # Running testing/lin
            os.chdir(os.path.join(os.getcwd(), 'lin'))
            print '--> testing/lin...',
            sys.stdout.flush()
            comm = './lapack_testing.py'
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\n\nPLASMA: Testing failed... '
                print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                f.write(output + error)
                f.close()
                sys.exit()
            print 'done'
            print error
            f.write(output + error)

            f.close()
            print '(log is in ', testlog, ')'

            os.chdir(os.path.join(os.getcwd(), '../..'))

        # Install
        print '--- Install PLASMA ---',
        sys.stdout.flush()
        if (self.version in self.oldversions):
            shutil.copy('lib/libplasma.a',
                        os.path.join(self.prefix, 'lib/libplasma.a'))
            shutil.copy('lib/libcoreblas.a',
                        os.path.join(self.prefix, 'lib/libcoreblas.a'))
            shutil.copy('include/plasma.h',
                        os.path.join(self.prefix, 'include/plasma.h'))
            shutil.copy('include/plasmaf.h',
                        os.path.join(self.prefix, 'include/plasmaf.h'))
            shutil.copy('include/plasma_m.h',
                        os.path.join(self.prefix, 'include/plasma_m.h'))
            shutil.copy('include/plasma_z.h',
                        os.path.join(self.prefix, 'include/plasma_z.h'))
            shutil.copy('include/plasma_c.h',
                        os.path.join(self.prefix, 'include/plasma_c.h'))
            shutil.copy('include/plasma_d.h',
                        os.path.join(self.prefix, 'include/plasma_d.h'))
            shutil.copy('include/plasma_s.h',
                        os.path.join(self.prefix, 'include/plasma_s.h'))
        else:
            comm = 'make install'
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\nPLASMA: make install failed... '
                print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                f.write(output + error)
                f.close()
                sys.exit()

        self.plasmalib = os.path.join(self.prefix, 'lib/libplasma.a ')
        self.coreblaslib = os.path.join(self.prefix, 'lib/libcoreblas.a ')

        os.chdir(savecwd)
        print "done. PLASMA is installed. Use it in moderation :-)"
Esempio n. 12
0
    def down_install(self):
        """ Download and install PLASMA """

        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'))

        versions = self.versions

        for ver in versions:
            cur_fname = "plasma_" + ver + ".tar.gz"

            if not os.path.isfile(os.path.join(os.getcwd(), cur_fname)):
                cur_url = self.urlbase + "/" + cur_fname
                print 'Downloading PLASMA from', cur_url
                downloader(cur_url, self.downcmd)
            else:
                print 'Already downloaded PLASMA to', cur_fname

            if os.path.isfile(os.path.join(os.getcwd(), cur_fname)):
                self.version = ver
                break

        comm = "gunzip -f " + cur_fname
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nPLASMA: cannot unzip " + cur_fname
            print "stderr:\n",'*'*40,'\n',error,'\n','*'*40
            sys.exit()

        cur_tar = cur_fname[:-3]
        comm = "tar xf " + cur_tar
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nPLASMA: cannot untar " + cur_tar
            print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()
        os.remove(cur_tar)

        # os.chdir(os.path.join(os.getcwd(),'plasma'))
        comm = 'ls -1 | grep plasma_ | grep -v tar | head -n 1'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\PLASMA: error changing to PLASMA dir'
            print 'stderr:\n','*'*40,'\n','   ->  no plasma 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_makeinc()

        print 'Compiling PLASMA...',
        sys.stdout.flush()
        comm = self.make+' lib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nPLASMA: error building PLASMA'
            print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
            writefile(os.path.join(savecwd,'log/plasmalog'), output+error)
            sys.exit()

        liblog = os.path.join(savecwd,'log/plasmalog')
        writefile(liblog, output+error)
        print 'Installation of PLASMA successful.'
        print '(log is in ',liblog,')'

        # Testings
        if self.testing == 1:

            # Open the file for writing the output and errors
            testlog = os.path.join(savecwd,'log/plasmatestlog')
            f = open(testlog, 'w')

            # Compiling tests
            print 'Compiling tests...',
            sys.stdout.flush()
            comm = self.make+ ' test'
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print '\n\nPLASMA: error building PLASMA test routines'
                print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
                f.write(output+error)
                f.close()
                sys.exit()
            print 'done'
            f.write(output+error)

            # Running in
            os.chdir(os.path.join(os.getcwd(),'testing'))
            print 'Running PLASMA tests on',self.nbcores, 'cores...(takes some time, feel free to grab a coffee!)'
            print '--> testing ...',
            sys.stdout.flush()
            comm = './plasma_testing.py -c ' + str(self.nbcores)
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\n\nPLASMA: Testing failed... '
                print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
                f.write(output+error)
                f.close()
                sys.exit()
            print 'done'
            print error
            f.write(output+error)

            # Running testing/lin
            os.chdir(os.path.join(os.getcwd(),'lin'))
            print '--> testing/lin...',
            sys.stdout.flush()
            comm = './lapack_testing.py'
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\n\nPLASMA: Testing failed... '
                print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
                f.write(output+error)
                f.close()
                sys.exit()
            print 'done'
            print error
            f.write(output+error)

            f.close()
            print '(log is in ',testlog,')'

            os.chdir(os.path.join(os.getcwd(),'../..'))

        # Install
        print '--- Install PLASMA ---',
        sys.stdout.flush()
        if (self.version in self.oldversions) :
            shutil.copy('lib/libplasma.a',    os.path.join(self.prefix,'lib/libplasma.a'))
            shutil.copy('lib/libcoreblas.a',  os.path.join(self.prefix,'lib/libcoreblas.a'))
            shutil.copy('include/plasma.h',   os.path.join(self.prefix,'include/plasma.h'))
            shutil.copy('include/plasmaf.h',  os.path.join(self.prefix,'include/plasmaf.h'))
            shutil.copy('include/plasma_m.h', os.path.join(self.prefix,'include/plasma_m.h'))
            shutil.copy('include/plasma_z.h', os.path.join(self.prefix,'include/plasma_z.h'))
            shutil.copy('include/plasma_c.h', os.path.join(self.prefix,'include/plasma_c.h'))
            shutil.copy('include/plasma_d.h', os.path.join(self.prefix,'include/plasma_d.h'))
            shutil.copy('include/plasma_s.h', os.path.join(self.prefix,'include/plasma_s.h'))
        else:
            comm = 'make install'
            (output, error, retz) = runShellCommand(comm, sys.stdout)
            if retz:
                print '\nPLASMA: make install failed... '
                print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
                f.write(output+error)
                f.close()
                sys.exit()

        self.plasmalib     = os.path.join(self.prefix,'lib/libplasma.a ')
        self.coreblaslib   = os.path.join(self.prefix,'lib/libcoreblas.a ')

        os.chdir(savecwd)
        print "done. PLASMA is installed. Use it in moderation :-)"
Esempio n. 13
0
    def down_install_tmg(self):

        print """
The libtmg from 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 BLAS...',
        comm = 'gunzip -f ' + self.lapversion + '.tgz'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nlibtmg: cannot unzip ' + self.lapversion + '.tgz'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()

        comm = 'tar xf ' + self.lapversion + '.tar'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nlibtmg: cannot untar ' + self.lapversion + '.tar'
            print 'stderr:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            sys.exit()
        os.remove(self.lapversion + '.tar')
        print 'done'

        # change to BLAS dir
        os.chdir(os.path.join(os.getcwd(), self.lapversion))

        # Write Makefile.in
        writefile(
            'make.inc', """
# -*- Makefile -*-
####################################################################
#  LAPACK make include file.                                       #
#  LAPACK, Version 3.3.1                                           #
#  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 + """
MAKE     = make -j 8
#
# 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.cblaslib + """
#
#  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    = liblapack.a
TMGLIB       = libtmg.a
EIGSRCLIB    = libeigsrc.a
LINSRCLIB    = liblinsrc.a
""")

        # compile and generate library
        print 'Compile and generate libtmg...',
        sys.stdout.flush()
        comm = self.make + ' tmglib'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print "\n\nlintmg: cannot compile libtmg"
            print "stderr:\n", "*" * 40, "\n", comm, '\n', error, "\n", "*" * 40
            sys.exit()

        log = output + error

        # write the log on a file
        log = log + output + error
        fulllog = os.path.join(savecwd, 'log/tmglog')
        writefile(fulllog, log)
        print 'Installation of libtmg.a successful.'
        print '(log is in ', fulllog, ')'

        # move libcblas.a to the lib directory
        shutil.copy('libtmg.a', os.path.join(self.prefix, 'lib/libtmg.a'))

        # set framework variables to point to the freshly installed BLAS library
        self.config.lapacklib = '-L' + os.path.join(
            self.prefix, 'lib') + ' -ltmg ' + self.config.lapacklib

        os.chdir(savecwd)

        # Check if the installation is successful
        self.plasma.verbose = 1
        self.check_tmg()
        self.plasma.verbose = 0
Esempio n. 14
0
    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 :-)"