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 # used in src/mat/impls/sbaij/seq/relax.h 73 self.libraries.saveLog() 74 if not self.libraries.isBGL(): 75 self.addDefine('USE_BACKWARD_LOOP','1') 76 self.logWrite(self.libraries.restoreLog()) 77 78 self.useFortranKernels = self.framework.argDB['with-fortran-kernels'] 79 if not hasattr(self.compilers, 'FC') and self.useFortranKernels: 80 raise RuntimeError('Cannot use fortran kernels without a Fortran compiler') 81 if self.useFortranKernels: 82 self.addDefine('USE_FORTRAN_KERNELS', 1) 83 if self.libraries.isBGL(): 84 self.addDefine('AssertAlignx(a,b)','call ALIGNX(a,b)') 85 else: 86 self.addDefine('AssertAlignx(a,b)',' ') 87 88 self.useAVX512Kernels = self.framework.argDB['with-avx512-kernels'] 89 if self.useAVX512Kernels: 90 self.addDefine('USE_AVX512_KERNELS', 1) 91 return 92 93 def configureISColorValueType(self): 94 '''Sets PETSC_IS_COLORING_VALUE_TYPE, PETSC_MPIU_IS_COLORING_VALUE_TYPE, and PETSC_IS_COLORING_MAX as required by ISColoring''' 95 self.isColorValueType = self.framework.argDB['with-is-color-value-type'] 96 if self.isColorValueType != 'char' and self.isColorValueType != 'short': 97 raise RuntimeError('Incorrect --with-is-color-value-type value specified. Can be either char or short. Specified value is :'+self.isColorValueType) 98 if self.isColorValueType == 'char': 99 max_value = 'UCHAR_MAX' 100 mpi_type = 'MPI_UNSIGNED_CHAR' 101 type_f = 'integer1' 102 else: 103 max_value = 'USHRT_MAX' 104 mpi_type = 'MPI_UNSIGNED_SHORT' 105 type_f = 'integer2' 106 107 self.addDefine('MPIU_IS_COLORING_VALUE_TYPE',mpi_type) 108 self.addDefine('IS_COLORING_MAX',max_value) 109 self.addDefine('IS_COLORING_VALUE_TYPE',self.isColorValueType) 110 self.addDefine('IS_COLORING_VALUE_TYPE_F',type_f) 111 return 112 113 def configure(self): 114 self.executeTest(self.configureLibraryOptions) 115 self.executeTest(self.configureISColorValueType) 116 return 117