PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/config/PETSc/packages/SuperLU_DIST.py

https://bitbucket.org/memmett/petsc-memmett-old
Python | 85 lines | 76 code | 5 blank | 4 comment | 7 complexity | de83502c1c146bd52161191914ad177f MD5 | raw file
  1. import PETSc.package
  2. class Configure(PETSc.package.NewPackage):
  3. def __init__(self, framework):
  4. PETSc.package.NewPackage.__init__(self, framework)
  5. self.gitcommit = '749f33d8104157767d443ff1a1d151642751486d' # v3.3 @ 2013-04-10
  6. self.giturls = ['https://bitbucket.org/petsc/pkg-superlu_dist.git']
  7. self.download = ['http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_dist_3.3.tar.gz']
  8. self.functions = ['set_default_options_dist']
  9. self.includes = ['superlu_ddefs.h']
  10. self.liblist = [['libsuperlu_dist_3.3.a']]
  11. self.requires32bitint = 0
  12. self.complex = 1
  13. # SuperLU_Dist does not work with --download-f-blas-lapack with Compaqf90 compiler on windows.
  14. # However it should work with intel ifort.
  15. self.worksonWindows = 1
  16. self.downloadonWindows= 1
  17. return
  18. def setupDependencies(self, framework):
  19. PETSc.package.NewPackage.setupDependencies(self, framework)
  20. self.blasLapack = framework.require('config.packages.BlasLapack',self)
  21. self.parmetis = framework.require('PETSc.packages.parmetis',self)
  22. self.deps = [self.mpi,self.blasLapack,self.parmetis]
  23. return
  24. def Install(self):
  25. import os
  26. g = open(os.path.join(self.packageDir,'make.inc'),'w')
  27. g.write('DSuperLUroot = '+self.packageDir+'\n')
  28. g.write('DSUPERLULIB = $(DSuperLUroot)/libsuperlu_dist_3.3.'+self.setCompilers.AR_LIB_SUFFIX+'\n')
  29. g.write('BLASDEF = -DUSE_VENDOR_BLAS\n')
  30. g.write('BLASLIB = '+self.libraries.toString(self.blasLapack.dlib)+'\n')
  31. g.write('IMPI = '+self.headers.toString(self.mpi.include)+'\n')
  32. g.write('MPILIB = '+self.libraries.toString(self.mpi.lib)+'\n')
  33. g.write('PMETISLIB = '+self.libraries.toString(self.parmetis.lib)+'\n')
  34. g.write('LIBS = $(DSUPERLULIB) $(BLASLIB) $(PMETISLIB) $(MPILIB)\n')
  35. g.write('ARCH = '+self.setCompilers.AR+'\n')
  36. g.write('ARCHFLAGS = '+self.setCompilers.AR_FLAGS+'\n')
  37. g.write('RANLIB = '+self.setCompilers.RANLIB+'\n')
  38. self.setCompilers.pushLanguage('C')
  39. g.write('CC = '+self.setCompilers.getCompiler()+' $(IMPI)\n') #build fails without $(IMPI)
  40. g.write('CFLAGS = '+self.setCompilers.getCompilerFlags()+'\n')
  41. g.write('LOADER = '+self.setCompilers.getLinker()+'\n')
  42. g.write('LOADOPTS = \n')
  43. self.setCompilers.popLanguage()
  44. # set blas/lapack name mangling
  45. if self.blasLapack.mangling == 'underscore':
  46. g.write('CDEFS = -DAdd_')
  47. elif self.blasLapack.mangling == 'caps':
  48. g.write('CDEFS = -DUpCase')
  49. else:
  50. g.write('CDEFS = -DNoChange')
  51. if self.libraryOptions.integerSize == 64:
  52. g.write(' -D_LONGINT')
  53. g.write('\n')
  54. # not sure what this is for
  55. g.write('NOOPTS = '+self.blasLapack.getSharedFlag(self.setCompilers.getCompilerFlags())+' '+self.blasLapack.getPrecisionFlag(self.setCompilers.getCompilerFlags())+' '+self.blasLapack.getWindowsNonOptFlags(self.setCompilers.getCompilerFlags())+'\n')
  56. g.close()
  57. if self.installNeeded('make.inc'):
  58. try:
  59. self.logPrintBox('Compiling superlu_dist; this may take several minutes')
  60. if not os.path.exists(os.path.join(self.packageDir,'lib')):
  61. os.makedirs(os.path.join(self.packageDir,'lib'))
  62. output,err,ret = PETSc.package.NewPackage.executeShellCommand('cd '+self.packageDir+' && make clean && make lib LAAUX="" && mv -f *.'+self.setCompilers.AR_LIB_SUFFIX+' '+os.path.join(self.installDir,self.libdir,'')+' && cp -f SRC/*.h '+os.path.join(self.installDir,self.includedir,''), timeout=2500, log = self.framework.log)
  63. except RuntimeError, e:
  64. raise RuntimeError('Error running make on SUPERLU_DIST: '+str(e))
  65. self.postInstall(output+err,'make.inc')
  66. return self.installDir
  67. def consistencyChecks(self):
  68. PETSc.package.NewPackage.consistencyChecks(self)
  69. if self.framework.argDB['with-'+self.package]:
  70. if not self.blasLapack.checkForRoutine('slamch'):
  71. raise RuntimeError('SuperLU_DIST requires the BLAS routine slamch()')
  72. self.framework.log.write('Found slamch() in BLAS library as needed by SuperLU_DIST\n')
  73. if not self.blasLapack.checkForRoutine('dlamch'):
  74. raise RuntimeError('SuperLU_DIST requires the BLAS routine dlamch()')
  75. self.framework.log.write('Found dlamch() in BLAS library as needed by SuperLU_DIST\n')
  76. if not self.blasLapack.checkForRoutine('xerbla'):
  77. raise RuntimeError('SuperLU_DIST requires the BLAS routine xerbla()')
  78. self.framework.log.write('Found xerbla() in BLAS library as needed by SuperLU_DIST\n')
  79. return