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;
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
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;
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;
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
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;
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
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
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;
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;
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
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;
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
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;
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;
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 :-)"
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
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
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;