コード例 #1
0
ファイル: framework.py プロジェクト: randyp/randyp
    def check_linking(self):
        """ Check if C main can be linked to Fortran subroutine """

        # This one checks if the linking command works out of the box or
        # if any specific flag is required. For example if the linker if the
        # Intel FORTRAN compiler, then the "-nofor_main" is usually required.
        # This function only checks if linker works but does not automatically
        # detect the required flags
        print 'Checking loader...',
        sys.stdout.flush()
        writefile('tmpf.f',"""
      subroutine fsub()
      write(*,*)'success'
      stop
      end\n""")
        writefile('tmpc.c',"""
      #if defined ADD_
      #define fsub fsub_
      #elif defined NOCHANGE
      #define fsub fsub
      #elif defined fcIsF2C
      #define fsub fsub_
      #elif defined UPCASE
      #define fsub FSUB
      #endif
      void main(){
      fsub();}\n""")

        ccomm = self.config.cc+' '+self.config.ccflags+' '+self.mangling+' -c -o tmpc.o tmpc.c'
        fcomm = self.config.fc+' '+self.config.fcflags+' -c -o tmpf.o tmpf.f'
        lcomm = self.config.fc+' '+self.config.ldflags_fc+' '+self.config.ld_fcmain+' -o lnk tmpf.o tmpc.o'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ',ccomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ',fcomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(lcomm)
        if retz:
            print """\n\nCOMMON: in check_linking: cannot link
            Cannot link a C main program to a Fortran77 subroutine
            Make sure that the appropriate flags are passed to the linker."""
            print 'command is: ',lcomm
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()


        killfiles(['lnk', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print 'works'
        return 1;
コード例 #2
0
ファイル: cblas.py プロジェクト: mawussi/BBLAS-ref
    def check_cblas(self):

        print "Checking if provided CBLAS works...",
        # This function simply generates a C program
        # that contains few calls to CBLAS routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile(
            'tmpc.c', """
int main(int argc, char*agv[]) {
  double da    = 2.0;
  double dx[2] = {1.0, 2.0};
  cblas_dscal(2, da, dx, 1);
  return 0;
}
\n""")

        ccomm = self.config.cc + ' -o tmpc.o ' + '-c tmpc.c ' + self.config.ccflags
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        ccomm = self.config.fc + ' -o tmpc ' + 'tmpc.o ' + self.config.fcflags + ' ' + self.config.cblaslib + ' ' + self.config.blaslib + ' ' + self.config.ldflags_fc + ' ' + self.config.ld_fcmain + ' -lm'
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if (retz != 0):
            if self.bblas.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            return -1

        killfiles(['tmpc.o', 'tmpc.c', 'tmpc'])
        print 'yes'

        return 0
コード例 #3
0
ファイル: blas.py プロジェクト: mawussi/BBLAS-ref
    def check_blas(self):

        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

        # Try to detect which BLAS is used
        if re.search('mkl', self.config.blaslib, re.IGNORECASE):
            self.config.blasname = "mkl"
        elif re.search('acml', self.config.blaslib, re.IGNORECASE):
            self.config.blasname = "acml"

        if self.config.blasname != "Unknown":
            if self.config.compiler == "Intel":
                self.config.ccflags += " -openmp"
                self.config.ldflags_c += " -openmp"
                self.config.ldflags_fc += " -openmp"
            elif self.config.compiler == "GNU":
                self.config.ccflags += " -fopenmp"
                self.config.ldflags_c += " -fopenmp"
                self.config.ldflags_fc += " -fopenmp"

        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
コード例 #4
0
ファイル: cblas.py プロジェクト: randyp/randyp
    def check_cblas(self):

        print "Checking if provided CBLAS works...",
        # This function simply generates a C program
        # that contains few calls to CBLAS routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
int main(int argc, char*agv[]) {
  double da    = 2.0;
  double dx[2] = {1.0, 2.0};
  cblas_dscal(2, da, dx, 1);
  return 0;
}
\n""")

        ccomm = self.config.cc+' -o tmpc.o '+'-c tmpc.c '+self.config.ccflags
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ccomm = self.config.fc+' -o tmpc '+'tmpc.o '+self.config.fcflags+' '+self.config.cblaslib+' '+self.config.blaslib+' '+self.config.ldflags_fc+' '+self.config.ld_fcmain+' -lm'
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nCBLAS: provided CBLAS cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o', 'tmpc.c','tmpc'])
        print 'yes'

        return 0;
コード例 #5
0
ファイル: lapcwrapper.py プロジェクト: pjzuk/GRPY
    def check_lapc(self):

        print "Checking if provided LAPACK C interface works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK C interface routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
#include <lapacke.h>
int main(int argc, char*agv[]) {
  double eps;
  eps = LAPACKE_dlamch('e');
  LAPACKE_dlatms_work(0, 0, 0, 'A', NULL, 'A', NULL, 0, 0., 0., 0, 0, 'A', NULL, 0, NULL );
  return 0;
}
\n""")

        ccomm = self.config.cc+' '+self.config.ldflags_c+' -o tmpc.o -c tmpc.c '+self.config.lapackinc
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ldflg = self.config.ld_fcmain+' '+self.config.ldflags_fc+' '+self.config.lapclib+' '+self.config.lapacklib+' '+self.config.blaslib+' -lm'
        ccomm = self.config.fc+' -o tmpc tmpc.o '+ldflg
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o','tmpc.c','tmpc'])
        print 'yes'

        return 0;
コード例 #6
0
ファイル: lapcwrapper.py プロジェクト: randyp/randyp
    def check_lapc(self):

        print "Checking if provided LAPACK C interface works...",
        # This function simply generates a C program
        # that contains few calls to LAPACK C interface routine and then
        # checks if compilation, linking and execution are succesful

        sys.stdout.flush()
        writefile('tmpc.c',"""
#include <lapacke.h>
int main(int argc, char*agv[]) {
  double eps;
  eps = LAPACKE_dlamch('e');
  return 0;
}
\n""")

        ccomm = self.config.cc+' '+self.config.ldflags_c+' -o tmpc.o -c tmpc.c '+self.config.lapackinc
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        ldflg = self.config.ld_fcmain+' '+self.config.ldflags_fc+' '+self.config.lapclib+' '+self.config.lapacklib+' '+self.config.blaslib+' -lm'
        ccomm = self.config.fc+' -o tmpc tmpc.o '+ldflg
        (output, error, retz) = runShellCommand(ccomm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nLAPCWRAPPER: provided LAPACK C interface cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            return -1;

        killfiles(['tmpc.o','tmpc.c','tmpc'])
        print 'yes'

        return 0;
コード例 #7
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def set_mangling(self):
        """ Sets the INTFACE variable in Bmake.inc """
        # This one generates a program equivalent to that in BLACS/INSTALL
        # that checks the mangling in FORTRAN function symbols
        print 'Setting Fortran mangling...',
        sys.stdout.flush()
        writefile(
            'tmpf.f', """
      program intface
      external c_intface
      integer i
      call c_intface(i)
      stop
      end\n""")
        writefile(
            'tmpc.c', """
      #include <stdio.h>
      void c_intface_(int *i){fprintf(stdout, \"-DADD_\");fflush(stdout);}
      void c_intface(int *i){fprintf(stdout, \"-DNOCHANGE\");fflush(stdout);}
      void c_intface__(int *i){fprintf(stdout, \"-DfcIsF2C\");fflush(stdout);}
      void C_INTFACE(int *i){fprintf(stdout, \"-DUPCASE\");fflush(stdout);}\n"""
        )

        ccomm = self.config.cc + ' ' + self.config.ccflags + ' -c tmpc.c -o tmpc.o'
        fcomm = self.config.fc + ' ' + self.config.fcflags + ' ' + self.config.ldflags_fc + ' tmpf.f tmpc.o -o xintface'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        comm = os.path.join(os.getcwd(), 'xintface')
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot run xintface'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        self.mangling = output
        killfiles(['xintface', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print self.mangling
        return 1
コード例 #8
0
    def check_tmg(self):

        print "Checking if provided LAPACK 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""")

        ldflg = self.config.cblaslib + ' ' + self.config.lapacklib + ' ' + self.config.blaslib + ' ' + self.config.ldflags_fc
        ccomm = self.config.fc + ' -o tmpf ' + 'tmpf.f ' + ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if (retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', ccomm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if (retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n', '*' * 40, '\n', comm, '\n', error, '\n', '*' * 40
            else:
                print "no"
            sys.exit()

        killfiles(['tmpf.f', 'tmpf'])
        print 'yes'

        return 0
コード例 #9
0
ファイル: tmg.py プロジェクト: randyp/randyp
    def check_tmg(self):

        print "Checking if provided LAPACK 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""")

        ldflg = self.config.cblaslib+' '+self.config.lapacklib+' '+self.config.blaslib+' '+self.config.ldflags_fc
        ccomm = self.config.fc+' -o tmpf '+'tmpf.f '+ldflg
        (output, error, retz) = runShellCommand(ccomm)

        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',ccomm,'\n',error,'\n','*'*40
            else:
                print "no"
            sys.exit()

        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if(retz != 0):
            if self.plasma.verbose:
                print '\n\nlibtmg: provided libtmg cannot be used! aborting...'
                print 'error is:\n','*'*40,'\n',comm,'\n',error,'\n','*'*40
            else:
                print "no"
            sys.exit()

        killfiles(['tmpf.f','tmpf'])
        print 'yes'

        return 0;
コード例 #10
0
ファイル: framework.py プロジェクト: randyp/randyp
 def set_download(self):
     """ Figures out how to download files """
     print 'Setting download command...'
     wget = 0
     urllib = 0
     # JULIE : Cut proxy stuff...was causing problems (see scalapack installer if you want it back)
     if urllib == 0:
         # if urllib2 is not present checks if wget is present
         # in the PATH and if yes it sets the download command
         # to be wget
         print "Checking availablility of wget...",
         path=str(os.getenv('PATH')).split(os.pathsep)
         for i in path:
             if (os.path.isfile(os.path.join(i,'wget'))):
                 print "available"
                 wget = 1
                 break
         if wget:
             # test wget
             print "Testing wget...",
             comm = 'wget --tries=2 --timeout=5 http://www.netlib.org/lapack/index'
             (output, error, retz) = runShellCommand(comm)
             if(retz != 0):
                 print 'not working.'
                 wget = -1
             else:
                 print "working"
                 self.downcmd="wget"
                 os.remove("index")
                 return
         else:
             # wget not available
             print "not available"
             wget=0
コード例 #11
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
 def set_download(self):
     """ Figures out how to download files """
     print 'Setting download command...'
     wget = 0
     urllib = 0
     # JULIE : Cut proxy stuff...was causing problems (see scalapack installer if you want it back)
     if urllib == 0:
         # if urllib2 is not present checks if wget is present
         # in the PATH and if yes it sets the download command
         # to be wget
         print "Checking availablility of wget...",
         path = str(os.getenv('PATH')).split(os.pathsep)
         for i in path:
             if (os.path.isfile(os.path.join(i, 'wget'))):
                 print "available"
                 wget = 1
                 break
         if wget:
             # test wget
             print "Testing wget...",
             comm = 'wget --tries=2 --timeout=5 http://www.netlib.org/lapack/index'
             (output, error, retz) = runShellCommand(comm)
             if (retz != 0):
                 print 'not working.'
                 wget = -1
             else:
                 print "working"
                 self.downcmd = "wget"
                 os.remove("index")
                 return
         else:
             # wget not available
             print "not available"
             wget = 0
コード例 #12
0
ファイル: framework.py プロジェクト: randyp/randyp
    def set_mangling(self):
        """ Sets the INTFACE variable in Bmake.inc """
        # This one generates a program equivalent to that in BLACS/INSTALL
        # that checks the mangling in FORTRAN function symbols
        print 'Setting Fortran mangling...',
        sys.stdout.flush()
        writefile('tmpf.f',"""
      program intface
      external c_intface
      integer i
      call c_intface(i)
      stop
      end\n""")
        writefile('tmpc.c',"""
      #include <stdio.h>
      void c_intface_(int *i){fprintf(stdout, \"-DADD_\");fflush(stdout);}
      void c_intface(int *i){fprintf(stdout, \"-DNOCHANGE\");fflush(stdout);}
      void c_intface__(int *i){fprintf(stdout, \"-DfcIsF2C\");fflush(stdout);}
      void C_INTFACE(int *i){fprintf(stdout, \"-DUPCASE\");fflush(stdout);}\n""")

        ccomm = self.config.cc+' '+self.config.ccflags+' -c tmpc.c -o tmpc.o'
        fcomm = self.config.fc+' '+self.config.fcflags+' '+self.config.ldflags_fc+' tmpf.f tmpc.o -o xintface'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot compile'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        comm = os.path.join(os.getcwd(),'xintface')
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: in set_mangling: cannot run xintface'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        self.mangling = output
        killfiles(['xintface', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print self.mangling
        return 1;
コード例 #13
0
ファイル: framework.py プロジェクト: randyp/randyp
    def cc_is_intel(self):
        comm = self.config.cc+' -V'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(error,'Intel(R) C')
        if isifort != -1:
            return 1

        return 0
コード例 #14
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def fc_is_xlf(self):
        comm = self.config.fc
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(output, 'xlf')
        if isifort != -1:
            return 1

        return 0
コード例 #15
0
ファイル: framework.py プロジェクト: randyp/randyp
    def fc_is_xlf(self):
        comm = self.config.fc
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(output,'xlf')
        if isifort != -1:
            return 1

        return 0
コード例 #16
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def cc_is_intel(self):
        comm = self.config.cc + ' -V'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(error, 'Intel(R) C')
        if isifort != -1:
            return 1

        return 0
コード例 #17
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def cc_is_gnu(self):
        comm = self.config.cc + ' -v'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(error, 'gcc')
        if isifort != -1:
            return 1

        return 0
コード例 #18
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def cc_is_xlc(self):
        comm = self.config.cc + ' -qversion'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(output, 'XL')
        if isifort != -1:
            return 1

        return 0
コード例 #19
0
ファイル: framework.py プロジェクト: randyp/randyp
    def cc_is_gnu(self):
        comm = self.config.cc+' --help'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(output,'gnu.org')
        if isifort != -1:
            return 1

        return 0
コード例 #20
0
ファイル: framework.py プロジェクト: randyp/randyp
    def cc_is_xlc(self):
        comm = self.config.cc+' -qversion'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(output,'XL')
        if isifort != -1:
            return 1

        return 0
コード例 #21
0
ファイル: framework.py プロジェクト: randyp/randyp
    def cleanup(self):
        """ Cleans up the installer directory """

        print "Cleaning up...",
        sys.stdout.flush()

        builddir = os.path.join(self.build)

        comm = 'rm -rf '+builddir
        #+' '+libdir+' '+logdir
        (output, error, retz) = runShellCommand(comm)

        print "done."
コード例 #22
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def check_cc(self):
        """ checks if cc works """
        # simply generates a C program containing a couple of calls
        # to MPI routines and checks if the compilation and execution
        # are succesful
        print 'Checking if cc works...',
        sys.stdout.flush()
        # generate
        writefile(
            'tmpc.c', """
            #include <stdio.h>
            int main(int argc, char **argv){
            int iam;
            fprintf(stdout, \"success\" );fflush(stdout);
            return 0;
            }\n""")

        # compile
        ccomm = self.config.cc + " " + self.config.ccflags + " " + self.config.ldflags_c + " -o tmpc " + os.path.join(
            os.getcwd(), "tmpc.c")
        (output, error, retz) = runShellCommand(ccomm)

        if retz:
            print '\n\nCOMMON: C compiler not working! aborting...'
            print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        # run
        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: cc not working! aborting...'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        # cleanup
        killfiles(['tmpc.c', 'tmpc'])
        print 'yes'
        return 0
コード例 #23
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def cleanup(self):
        """ Cleans up the installer directory """

        print "Cleaning up...",
        sys.stdout.flush()

        builddir = os.path.join(self.build)

        comm = 'rm -rf ' + builddir
        #+' '+libdir+' '+logdir
        (output, error, retz) = runShellCommand(comm)

        print "done."
コード例 #24
0
ファイル: framework.py プロジェクト: randyp/randyp
    def check_cc(self):
        """ checks if cc works """
        # simply generates a C program containing a couple of calls
        # to MPI routines and checks if the compilation and execution
        # are succesful
        print 'Checking if cc works...',
        sys.stdout.flush()
        # generate
        writefile('tmpc.c',"""
            #include <stdio.h>
            int main(int argc, char **argv){
            int iam;
            fprintf(stdout, \"success\" );fflush(stdout);
            return 0;
            }\n""")

        # compile
        ccomm = self.config.cc+" "+self.config.ccflags+" "+self.config.ldflags_c+" -o tmpc "+os.path.join(os.getcwd(),"tmpc.c")
        (output, error, retz) = runShellCommand(ccomm)

        if retz:
            print '\n\nCOMMON: C compiler not working! aborting...'
            print 'stderr:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # run
        comm = './tmpc'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: cc not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # cleanup
        killfiles(['tmpc.c','tmpc'])
        print 'yes'
        return 0;
コード例 #25
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def check_fc(self):
        """ check if the Fortran compiler works """
        # simply generates a F77 program and checks if the compilation and execution
        # are succesful
        print "Checking if the Fortran compiler works...",
        sys.stdout.flush()
        # generate
        writefile(
            "tmpf.f", """
      program ftest
      integer i
      print*,'success'
      stop
      end\n""")

        # compile
        fcomm = self.config.fc + ' ' + self.config.fcflags + " " + self.config.ldflags_fc + ' -o tmpf ' + 'tmpf.f'
        (output, error, retz) = runShellCommand(fcomm)

        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        # run
        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        # cleanup
        killfiles(['tmpf.f', 'tmpf', 'tmpf.o'])
        print 'yes'

        return 0
コード例 #26
0
ファイル: framework.py プロジェクト: randyp/randyp
    def check_fc(self):
        """ check if the Fortran compiler works """
        # simply generates a F77 program and checks if the compilation and execution
        # are succesful
        print "Checking if the Fortran compiler works...",
        sys.stdout.flush()
        # generate
        writefile("tmpf.f","""
      program ftest
      integer i
      print*,'success'
      stop
      end\n""")

        # compile
        fcomm = self.config.fc+' '+self.config.fcflags+" "+self.config.ldflags_fc+' -o tmpf '+'tmpf.f'
        (output, error, retz) = runShellCommand(fcomm)

        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # run
        comm = './tmpf'
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nCOMMON: the Fortran compiler is not working! aborting...'
            print 'error is:\n','*'*40,'\n',error,'\n','*'*40
            sys.exit()

        # cleanup
        killfiles(['tmpf.f','tmpf','tmpf.o'])
        print 'yes'

        return 0;
コード例 #27
0
ファイル: blas.py プロジェクト: randyp/randyp
    def check_blas(self):

        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;
コード例 #28
0
ファイル: framework.py プロジェクト: randyp/randyp
    def cc_is_pgi(self):
        comm = self.config.cc+' -V'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(error,'pgicc')
        if isifort != -1:
            return 1
        isifort = string.find(error,'Portland')
        if isifort != -1:
            return 1
        isifort = string.find(output,'pgicc')
        if isifort != -1:
            return 1
        isifort = string.find(output,'Portland')
        if isifort != -1:
            return 1

        return 0
コード例 #29
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def cc_is_pgi(self):
        comm = self.config.cc + ' -V'
        (output, error, retz) = runShellCommand(comm)
        isifort = string.find(error, 'pgicc')
        if isifort != -1:
            return 1
        isifort = string.find(error, 'Portland')
        if isifort != -1:
            return 1
        isifort = string.find(output, 'pgicc')
        if isifort != -1:
            return 1
        isifort = string.find(output, 'Portland')
        if isifort != -1:
            return 1

        return 0
コード例 #30
0
ファイル: blas.py プロジェクト: randyp/randyp
    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)
コード例 #31
0
ファイル: cblas.py プロジェクト: mawussi/BBLAS-ref
    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()
コード例 #32
0
ファイル: plasma.py プロジェクト: randyp/randyp
    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 :-)"
コード例 #33
0
ファイル: plasma.py プロジェクト: 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 :-)"
コード例 #34
0
ファイル: tmg.py プロジェクト: 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
コード例 #35
0
ファイル: bblas.py プロジェクト: mawussi/BBLAS-ref
    def install(self):
        """ Compile, test, and install BBLAS """

        savecwd = os.getcwd()  # Location we are building in

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

        self.write_makeinc()

        print 'Compiling BBLAS and tests...',
        sys.stdout.flush()
        comm = "(cd ../testing && " + self.make + ")"  # System command to be run
        (output, error, retz) = runShellCommand(comm)
        if retz:
            print '\n\nBBLAS: Error building BBLAS'
            print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
            writefile(os.path.join(savecwd, 'log/bblaslog'), output + error)
            sys.exit()

        liblog = os.path.join(savecwd, 'log/bblaslog')
        writefile(liblog, output + error)
        print 'Compilation of BBLAS and tests successful.'
        print '(log is in ', liblog, ')\n'
        sys.stdout.flush()

        ##
        # Build documentation if requested
        ##
        if self.documentation == 1:
            print "=" * 40
            print "  Building Documentation"
            print "=" * 40
            print "Output saved in ./docs..."
            sys.stdout.flush()
            comm = "(cd ../ && doxygen Doxyfile)"
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print "\n\nBBLAS: Error building documentation"
                print "stderr:\n", "*" * 40, "\n", error, "\n", "*" * 40
                writefile(os.path.join(savecwd, "log/bblaslog"),
                          output + error)
                sys.exit()
            writefile(liblog, output + error)

        ##
        # Run tests if requested
        ##
        if self.testing == 1:

            # Open the file for writing the output and errors
            testlog = os.path.join(savecwd, 'log/bblastestlog')
            f = open(testlog, 'w')
            print "\n"
            print "=" * 40
            print "  Running Basic Tests"
            print "=" * 40
            print "Output saved to ", os.path.join(savecwd,
                                                   'log/bblastestlog'), "..."
            sys.stdout.flush()

            # OpenMP Tests
            print 'Running OpenMP tests...',
            sys.stdout.flush()
            comm = "(cd ../testing && ./run_tests.py --other)"
            (output, error, retz) = runShellCommand(comm)
            if retz:
                print '\n\nBBLAS: Error running OpenMP tests...'
                print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                f.write(output + error)
                f.close()
                sys.exit()
            print 'Completed OpenMP tests...'
            sys.stdout.flush()
            f.write(output + error)

            if self.config.blasname == "mkl":
                # MKL Tests
                print 'Running MKL tests...',
                sys.stdout.flush()
                comm = "(cd ../testing && ./run_tests.py --gemm --batch_opts f --mkl)"
                (output, error, retz) = runShellCommand(comm)
                if retz:
                    print '\n\nBBLAS: Error running MKL tests...'
                    print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                    f.write(output + error)
                    f.close()
                    sys.exit()
                print 'Completed MKL tests...'
                sys.stdout.flush()
                f.write(output + error)

            if self.usecuda:
                # CuBLAS Tests
                print 'Running CUBLAS tests...',
                sys.stdout.flush()
                comm = "(cd ../testing && ./run_tests.py --gemm --trsm --batch_opts f --cublas)"
                (output, error, retz) = runShellCommand(comm)
                if retz:
                    print '\n\nBBLAS: Error running CUBLAS tests...'
                    print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                    f.write(output + error)
                    f.close()
                    sys.exit()
                print 'Completed CUBLAS tests...'
                sys.stdout.flush()
                f.write(output + error)

            if self.usemagma:
                # MAGMA Tests
                print 'Running MAGMA tests...',
                sys.stdout.flush()
                comm = "(cd ../testing && ./run_tests.py --gemm --trsm --herk --batch_opts f --magma)"
                (output, error, retz) = runShellCommand(comm)
                if retz:
                    print '\n\nBBLAS: Error running MAGMA tests...'
                    print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
                    f.write(output + error)
                    f.close()
                    sys.exit()
                print 'Completed MAGMA tests...'
                sys.stdout.flush()
                f.write(output + error)

            print "Completed all testing..."
            sys.stdout.flush()

        # Install
        print "\n"
        print "=" * 40
        print " Install BBLAS"
        print "=" * 40
        comm = 'make install'
        (output, error, retz) = runShellCommand(comm, sys.stdout)
        if retz:
            print '\nBBLAS: make install failed... '
            print 'stderr:\n', '*' * 40, '\n', error, '\n', '*' * 40
            f.write(output + error)
            f.close()
            sys.exit()

        ##
        # The BBLAS library file
        ##
        self.bblaslib = os.path.join(self.prefix, 'lib/libbblas.a ')

        os.chdir(savecwd)
        print "BBLAS is installed. Use it wisely! :-)"
コード例 #36
0
ファイル: lapcwrapper.py プロジェクト: pjzuk/GRPY
    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()
コード例 #37
0
ファイル: framework.py プロジェクト: mawussi/BBLAS-ref
    def check_linking(self):
        """ Check if C main can be linked to Fortran subroutine """

        # This one checks if the linking command works out of the box or
        # if any specific flag is required. For example if the linker if the
        # Intel FORTRAN compiler, then the "-nofor_main" is usually required.
        # This function only checks if linker works but does not automatically
        # detect the required flags
        print 'Checking loader...',
        sys.stdout.flush()
        writefile(
            'tmpf.f', """
      subroutine fsub()
      write(*,*)'success'
      stop
      end\n""")
        writefile(
            'tmpc.c', """
      #if defined ADD_
      #define fsub fsub_
      #elif defined NOCHANGE
      #define fsub fsub
      #elif defined fcIsF2C
      #define fsub fsub_
      #elif defined UPCASE
      #define fsub FSUB
      #endif
      void main(){
      fsub();}\n""")

        ccomm = self.config.cc + ' ' + self.config.ccflags + ' ' + self.mangling + ' -c -o tmpc.o tmpc.c'
        fcomm = self.config.fc + ' ' + self.config.fcflags + ' -c -o tmpf.o tmpf.f'
        lcomm = self.config.fc + ' ' + self.config.ldflags_fc + ' ' + self.config.ld_fcmain + ' -o lnk tmpf.o tmpc.o'

        (output, error, retz) = runShellCommand(ccomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ', ccomm
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        (output, error, retz) = runShellCommand(fcomm)
        if retz:
            print '\n\nCOMMON: in check_linking: cannot compile'
            print 'command is: ', fcomm
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        (output, error, retz) = runShellCommand(lcomm)
        if retz:
            print """\n\nCOMMON: in check_linking: cannot link
            Cannot link a C main program to a Fortran77 subroutine
            Make sure that the appropriate flags are passed to the linker."""
            print 'command is: ', lcomm
            print 'error is:\n', '*' * 40, '\n', error, '\n', '*' * 40
            sys.exit()

        killfiles(['lnk', 'tmpf.f', 'tmpf.o', 'tmpc.c', 'tmpc.o'])

        print 'works'
        return 1
コード例 #38
0
ファイル: cblas.py プロジェクト: randyp/randyp
    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()
コード例 #39
0
ファイル: lapack.py プロジェクト: randyp/randyp
    def check_lapack(self):

        print "Checking if provided LAPACK 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
      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.plasma.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.plasma.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 "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.plasma.needtmg = 1
        else:
            comm = './tmpf'
            (output, error, retz) = runShellCommand(comm)
            if(retz != 0):
                print 'no'
                self.plasma.needtmg = 1;
            else:
                self.plasma.needtmg = 0;
                print 'yes'
        killfiles(['tmpf.f','tmpf'])

        return 0;
コード例 #40
0
ファイル: lapack.py プロジェクト: randyp/randyp
    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()
コード例 #41
0
    def check_lapack(self):

        print "Checking if provided LAPACK 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
      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.bblas.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.bblas.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 "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.bblas.needtmg = 1
        else:
            comm = './tmpf'
            (output, error, retz) = runShellCommand(comm)
            if (retz != 0):
                print 'no'
                self.bblas.needtmg = 1
            else:
                self.bblas.needtmg = 0
                print 'yes'
        killfiles(['tmpf.f', 'tmpf'])

        return 0
コード例 #42
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
コード例 #43
0
ファイル: blas.py プロジェクト: mawussi/BBLAS-ref
    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)
コード例 #44
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 :-)"