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