PageRenderTime 68ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/config/PETSc/options/libraryOptions.py

https://bitbucket.org/karpeev/petsc
Python | 110 lines | 108 code | 1 blank | 1 comment | 4 complexity | c834753b6ee55bae83e9f45117555d43 MD5 | raw file
  1. #!/usr/bin/env python
  2. from __future__ import generators
  3. import user
  4. import config.base
  5. import os
  6. class Configure(config.base.Configure):
  7. def __init__(self, framework):
  8. config.base.Configure.__init__(self, framework)
  9. self.headerPrefix = ''
  10. self.substPrefix = ''
  11. return
  12. def __str__(self):
  13. return ''
  14. def setupHelp(self, help):
  15. import nargs
  16. help.addArgument('PETSc', '-with-log=<bool>', nargs.ArgBool(None, 1, 'Activate logging code in PETSc'))
  17. help.addArgument('PETSc', '-with-threadsafety=<bool>', nargs.ArgBool(None, 0, 'Allow individual threads in PETSc to call PETSc routines'))
  18. help.addArgument('PETSc', '-with-info=<bool>', nargs.ArgBool(None, 1, 'Activate PetscInfo() (i.e. -info) code in PETSc'))
  19. help.addArgument('PETSc', '-with-ctable=<bool>', nargs.ArgBool(None, 1, 'Activate CTABLE hashing for certain search functions - to conserve memory'))
  20. help.addArgument('PETSc', '-with-fortran-kernels=<bool>', nargs.ArgBool(None, 0, 'Use Fortran for linear algebra kernels'))
  21. help.addArgument('PETSc', '-with-is-color-value-type=<char,short>',nargs.ArgString(None, 'short', 'char, short can store 256, 65536 colors'))
  22. return
  23. def setupDependencies(self, framework):
  24. config.base.Configure.setupDependencies(self, framework)
  25. self.debugging = framework.require('PETSc.options.debugging', self)
  26. self.compilers = framework.require('config.compilers', self)
  27. self.libraries = framework.require('config.libraries', self)
  28. self.types = framework.require('config.types', self)
  29. return
  30. def configureLibraryOptions(self):
  31. '''Sets PETSC_USE_DEBUG, PETSC_USE_INFO, PETSC_USE_LOG, PETSC_USE_CTABLE and PETSC_USE_FORTRAN_KERNELS'''
  32. '''Also sets PETSC_AssertAlignx() in Fortran and PETSC_Alignx() in C for IBM BG/P compiler '''
  33. if self.framework.argDB['with-threadsafety']:
  34. self.addDefine('HAVE_THREADSAFETY',1)
  35. self.useThreadSafety = 1
  36. else:
  37. self.useThreadSafety = 0
  38. if self.useThreadSafety and self.framework.argDB['with-log']:
  39. raise RuntimeError('Must use --with-log=0 with --with-threadsafety')
  40. self.useLog = self.framework.argDB['with-log']
  41. self.addDefine('USE_LOG', self.useLog)
  42. if self.debugging.debugging:
  43. self.addDefine('USE_DEBUG',1)
  44. elif not config.setCompilers.Configure.isIBM(self.framework.getCompiler()):
  45. # IBM XLC version 12.1 (BG/Q and POWER) miscompiles PetscMalloc3()
  46. # by reordering "*(void**)&ptr = x" as though ptr was not modified
  47. # by this statement.
  48. self.addDefine('USE_MALLOC_COALESCED',1)
  49. self.useInfo = self.framework.argDB['with-info']
  50. self.addDefine('USE_INFO', self.useInfo)
  51. self.useCtable = self.framework.argDB['with-ctable']
  52. if self.useCtable:
  53. self.addDefine('USE_CTABLE', '1')
  54. # used in src/mat/impls/sbaij/seq/relax.h
  55. if not self.libraries.isBGL():
  56. self.addDefine('USE_BACKWARD_LOOP','1')
  57. self.useFortranKernels = self.framework.argDB['with-fortran-kernels']
  58. if not hasattr(self.compilers, 'FC') and self.useFortranKernels:
  59. raise RuntimeError('Cannot use fortran kernels without a Fortran compiler')
  60. if self.useFortranKernels:
  61. self.addDefine('USE_FORTRAN_KERNELS', 1)
  62. if self.libraries.isBGL():
  63. self.addDefine('AssertAlignx(a,b)','call ALIGNX(a,b)')
  64. else:
  65. self.addDefine('AssertAlignx(a,b)',' ')
  66. if self.libraries.isBGL():
  67. self.addDefine('Alignx(a,b)','__alignx(a,b)')
  68. else:
  69. self.addDefine('Alignx(a,b)',' ')
  70. return
  71. def configureISColorValueType(self):
  72. '''Sets PETSC_IS_COLOR_VALUE_TYPE, MPIU_COLORING_VALUE, IS_COLORING_MAX required by ISColor'''
  73. self.isColorValueType = self.framework.argDB['with-is-color-value-type']
  74. if self.isColorValueType != 'char' and self.isColorValueType != 'short':
  75. raise RuntimeError('Incorrect --with-is-color-value-type value specified. Can be either char or short. Specified value is :'+self.isColorValueType)
  76. if self.isColorValueType == 'char':
  77. max = pow(2,self.types.sizes['known-sizeof-char']*self.types.bits_per_byte)-1
  78. mpi_type = 'MPI_UNSIGNED_CHAR'
  79. sz = 'PETSC_SIZEOF_CHAR'
  80. else:
  81. max = pow(2,self.types.sizes['known-sizeof-short']*self.types.bits_per_byte)-1
  82. mpi_type = 'MPI_UNSIGNED_SHORT'
  83. sz = 'PETSC_SIZEOF_SHORT'
  84. self.framework.addDefine('MPIU_COLORING_VALUE',mpi_type)
  85. self.framework.addDefine('IS_COLORING_MAX',max)
  86. self.addDefine('IS_COLOR_VALUE_TYPE', self.isColorValueType)
  87. self.addDefine('IS_COLOR_VALUE_TYPE_SIZE', sz)
  88. return
  89. def configure(self):
  90. self.executeTest(self.configureLibraryOptions)
  91. self.executeTest(self.configureISColorValueType)
  92. return