1from __future__ import generators 2import config.base 3import os 4 5class Configure(config.base.Configure): 6 def __init__(self, framework): 7 config.base.Configure.__init__(self, framework) 8 self.headerPrefix = '' 9 self.substPrefix = '' 10 return 11 12 def __str__(self): 13 return '' 14 15 def setupHelp(self, help): 16 import nargs 17 help.addArgument('PETSc', '-with-log=<bool>', nargs.ArgBool(None, 1, 'Activate logging code in PETSc')) 18 help.addArgument('PETSc', '-with-threadsafety=<bool>', nargs.ArgBool(None, 0, 'Allow individual threads in PETSc to call PETSc routines')) 19 help.addArgument('PETSc', '-with-info=<bool>', nargs.ArgBool(None, 1, 'Activate PetscInfo() (i.e. -info) code in PETSc')) 20 help.addArgument('PETSc', '-with-ctable=<bool>', nargs.ArgBool(None, 1, 'Use hash maps in certain places in PETSc, instead of non-memory-scalable arrays')) 21 help.addArgument('PETSc', '-with-dmlandau-3d=<bool>', nargs.ArgBool(None, 0, 'Enable full 3D DM Landau, default is 2.5D')) 22 help.addArgument('PETSc', '-with-fortran-kernels=<bool>', nargs.ArgBool(None, 0, 'Use Fortran for linear algebra kernels')) 23 help.addArgument('PETSc', '-with-avx512-kernels=<bool>', nargs.ArgBool(None, 1, 'Use AVX-512 intrinsics for linear algebra kernels when available')) 24 help.addArgument('PETSc', '-with-is-color-value-type=<char,short>',nargs.ArgString(None, 'short', 'char, short can store 256, 65536 colors')) 25 return 26 27 def setupDependencies(self, framework): 28 config.base.Configure.setupDependencies(self, framework) 29 self.compilers = framework.require('config.compilers', self) 30 self.setCompilers = framework.require('config.setCompilers', self) 31 self.libraries = framework.require('config.libraries', self) 32 self.types = framework.require('config.types', self) 33 self.compilerFlags = framework.require('config.compilerFlags', self) 34 self.sharedLibraries = framework.require('PETSc.options.sharedLibraries', None) 35 self.petscConfigure = framework.require('PETSc.Configure', None) 36 return 37 38 def configureLibraryOptions(self): 39 '''Sets PETSC_USE_DEBUG, PETSC_USE_INFO, PETSC_USE_LOG, PETSC_USE_CTABLE, PETSC_USE_DMLANDAU_2D, PETSC_USE_FORTRAN_KERNELS, and PETSC_USE_AVX512_KERNELS''' 40 '''Also sets PETSC_AssertAlignx() in Fortran for IBM BG/P compiler ''' 41 if self.framework.argDB['with-threadsafety']: 42 self.addDefine('HAVE_THREADSAFETY',1) 43 self.useThreadSafety = 1 44 else: 45 self.useThreadSafety = 0 46 47 if self.useThreadSafety and not ((self.sharedLibraries.useShared and self.setCompilers.dynamicLibraries) or self.framework.argDB['with-single-library']): 48 raise RuntimeError('Must use --with-shared-libraries or --with-single-library with --with-threadsafety') 49 50 self.useLog = self.framework.argDB['with-log'] 51 self.addDefine('USE_LOG', self.useLog) 52 53 if self.compilerFlags.debugging: 54 self.addDefine('USE_DEBUG',1) 55 elif not config.setCompilers.Configure.isIBM(self.framework.getCompiler(), self.log): 56 # IBM XLC version 12.1 (BG/Q and POWER) miscompiles PetscMalloc3() 57 # by reordering "*(void**)&ptr = x" as though ptr was not modified 58 # by this statement. 59 self.addDefine('USE_MALLOC_COALESCED',1) 60 61 self.useInfo = self.framework.argDB['with-info'] 62 self.addDefine('USE_INFO', self.useInfo) 63 64 self.useCtable = self.framework.argDB['with-ctable'] 65 if self.useCtable: 66 self.addDefine('USE_CTABLE', '1') 67 68 self.useDmLandau3d = self.framework.argDB['with-dmlandau-3d'] 69 if not self.useDmLandau3d: 70 self.addDefine('USE_DMLANDAU_2D',1) 71 72 self.useFortranKernels = self.framework.argDB['with-fortran-kernels'] 73 if not hasattr(self.compilers, 'FC') and self.useFortranKernels: 74 raise RuntimeError('Cannot use fortran kernels without a Fortran compiler') 75 if self.useFortranKernels: 76 self.addDefine('USE_FORTRAN_KERNELS', 1) 77 self.addDefine('AssertAlignx(a,b)',' ') 78 79 self.useAVX512Kernels = self.framework.argDB['with-avx512-kernels'] 80 if self.useAVX512Kernels: 81 self.addDefine('USE_AVX512_KERNELS', 1) 82 return 83 84 def configureISColorValueType(self): 85 '''Sets PETSC_IS_COLORING_VALUE_TYPE, PETSC_MPIU_IS_COLORING_VALUE_TYPE, and PETSC_IS_COLORING_MAX as required by ISColoring''' 86 self.isColorValueType = self.framework.argDB['with-is-color-value-type'] 87 if self.isColorValueType != 'char' and self.isColorValueType != 'short': 88 raise RuntimeError('Incorrect --with-is-color-value-type value specified. Can be either char or short. Specified value is :'+self.isColorValueType) 89 if self.isColorValueType == 'char': 90 max_value = 'UCHAR_MAX' 91 mpi_type = 'MPI_UNSIGNED_CHAR' 92 type_f = 'integer1' 93 else: 94 max_value = 'USHRT_MAX' 95 mpi_type = 'MPI_UNSIGNED_SHORT' 96 type_f = 'integer2' 97 98 self.addDefine('MPIU_IS_COLORING_VALUE_TYPE',mpi_type) 99 self.addDefine('IS_COLORING_MAX',max_value) 100 self.addDefine('IS_COLORING_VALUE_TYPE',self.isColorValueType) 101 self.addDefine('IS_COLORING_VALUE_TYPE_F',type_f) 102 return 103 104 def configure(self): 105 self.executeTest(self.configureLibraryOptions) 106 self.executeTest(self.configureISColorValueType) 107 return 108