19d310bb7SBarry Smithfrom __future__ import generators 29d310bb7SBarry Smithimport config.base 39d310bb7SBarry Smithimport os 49d310bb7SBarry Smith 59d310bb7SBarry Smithclass Configure(config.base.Configure): 69d310bb7SBarry Smith def __init__(self, framework): 79d310bb7SBarry Smith config.base.Configure.__init__(self, framework) 89d310bb7SBarry Smith self.headerPrefix = '' 99d310bb7SBarry Smith self.substPrefix = '' 109d310bb7SBarry Smith return 119d310bb7SBarry Smith 129d310bb7SBarry Smith def __str__(self): 139d310bb7SBarry Smith return '' 149d310bb7SBarry Smith 159d310bb7SBarry Smith def setupHelp(self, help): 169d310bb7SBarry Smith import nargs 179d310bb7SBarry Smith help.addArgument('PETSc', '-with-log=<bool>', nargs.ArgBool(None, 1, 'Activate logging code in PETSc')) 1822b6d1caSBarry Smith help.addArgument('PETSc', '-with-threadsafety=<bool>', nargs.ArgBool(None, 0, 'Allow individual threads in PETSc to call PETSc routines')) 199d310bb7SBarry Smith help.addArgument('PETSc', '-with-info=<bool>', nargs.ArgBool(None, 1, 'Activate PetscInfo() (i.e. -info) code in PETSc')) 209d310bb7SBarry Smith help.addArgument('PETSc', '-with-ctable=<bool>', nargs.ArgBool(None, 1, 'Activate CTABLE hashing for certain search functions - to conserve memory')) 2175919039Smarkadams4 help.addArgument('PETSc', '-with-dmlandau-3d=<bool>', nargs.ArgBool(None, 0, 'Enable full 3D DM Landau, default is 2.5D')) 229d310bb7SBarry Smith help.addArgument('PETSc', '-with-fortran-kernels=<bool>', nargs.ArgBool(None, 0, 'Use Fortran for linear algebra kernels')) 2315681d7cSHong Zhang help.addArgument('PETSc', '-with-avx512-kernels=<bool>', nargs.ArgBool(None, 1, 'Use AVX-512 intrinsics for linear algebra kernels when available')) 249d310bb7SBarry Smith help.addArgument('PETSc', '-with-is-color-value-type=<char,short>',nargs.ArgString(None, 'short', 'char, short can store 256, 65536 colors')) 259d310bb7SBarry Smith return 269d310bb7SBarry Smith 279d310bb7SBarry Smith def setupDependencies(self, framework): 289d310bb7SBarry Smith config.base.Configure.setupDependencies(self, framework) 299d310bb7SBarry Smith self.compilers = framework.require('config.compilers', self) 3060da17ecSBarry Smith self.setCompilers = framework.require('config.setCompilers', self) 319d310bb7SBarry Smith self.libraries = framework.require('config.libraries', self) 329d310bb7SBarry Smith self.types = framework.require('config.types', self) 333d744f9eSBarry Smith self.compilerFlags = framework.require('config.compilerFlags', self) 3460da17ecSBarry Smith self.sharedLibraries = framework.require('PETSc.options.sharedLibraries', None) 3560da17ecSBarry Smith self.petscConfigure = framework.require('PETSc.Configure', None) 369d310bb7SBarry Smith return 379d310bb7SBarry Smith 389d310bb7SBarry Smith def configureLibraryOptions(self): 39984ed092SMark Adams '''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*9fb7294dSPierre Jolivet '''Also sets PETSC_AssertAlignx() in Fortran for IBM BG/P compiler ''' 4122b6d1caSBarry Smith if self.framework.argDB['with-threadsafety']: 42f79c285dSBarry Smith self.addDefine('HAVE_THREADSAFETY',1) 4322b6d1caSBarry Smith self.useThreadSafety = 1 4422b6d1caSBarry Smith else: 4522b6d1caSBarry Smith self.useThreadSafety = 0 4622b6d1caSBarry Smith 4722b6d1caSBarry Smith if self.useThreadSafety and self.framework.argDB['with-log']: 4822b6d1caSBarry Smith raise RuntimeError('Must use --with-log=0 with --with-threadsafety') 4922b6d1caSBarry Smith 50fb33c7d2SBarry Smith if self.useThreadSafety and not ((self.sharedLibraries.useShared and self.setCompilers.dynamicLibraries) or self.framework.argDB['with-single-library']): 5160da17ecSBarry Smith raise RuntimeError('Must use --with-shared-libraries or --with-single-library with --with-threadsafety') 5260da17ecSBarry Smith 539d310bb7SBarry Smith self.useLog = self.framework.argDB['with-log'] 549d310bb7SBarry Smith self.addDefine('USE_LOG', self.useLog) 559d310bb7SBarry Smith 563d744f9eSBarry Smith if self.compilerFlags.debugging: 572e3e7a57SBarry Smith if self.useThreadSafety: 582e3e7a57SBarry Smith raise RuntimeError('Must use --with-debugging=0 with --with-threadsafety') 59f79c285dSBarry Smith self.addDefine('USE_DEBUG',1) 607fca349cSMatthew G. Knepley elif not config.setCompilers.Configure.isIBM(self.framework.getCompiler(), self.log): 619d310bb7SBarry Smith # IBM XLC version 12.1 (BG/Q and POWER) miscompiles PetscMalloc3() 629d310bb7SBarry Smith # by reordering "*(void**)&ptr = x" as though ptr was not modified 639d310bb7SBarry Smith # by this statement. 649d310bb7SBarry Smith self.addDefine('USE_MALLOC_COALESCED',1) 659d310bb7SBarry Smith 669d310bb7SBarry Smith self.useInfo = self.framework.argDB['with-info'] 679d310bb7SBarry Smith self.addDefine('USE_INFO', self.useInfo) 689d310bb7SBarry Smith 699d310bb7SBarry Smith self.useCtable = self.framework.argDB['with-ctable'] 709d310bb7SBarry Smith if self.useCtable: 719d310bb7SBarry Smith self.addDefine('USE_CTABLE', '1') 729d310bb7SBarry Smith 7375919039Smarkadams4 self.useDmLandau3d = self.framework.argDB['with-dmlandau-3d'] 7475919039Smarkadams4 if not self.useDmLandau3d: 75984ed092SMark Adams self.addDefine('USE_DMLANDAU_2D',1) 76984ed092SMark Adams 779d310bb7SBarry Smith # used in src/mat/impls/sbaij/seq/relax.h 783cafa982SMatthew G. Knepley self.libraries.saveLog() 799d310bb7SBarry Smith if not self.libraries.isBGL(): 809d310bb7SBarry Smith self.addDefine('USE_BACKWARD_LOOP','1') 813cafa982SMatthew G. Knepley self.logWrite(self.libraries.restoreLog()) 829d310bb7SBarry Smith 839d310bb7SBarry Smith self.useFortranKernels = self.framework.argDB['with-fortran-kernels'] 849d310bb7SBarry Smith if not hasattr(self.compilers, 'FC') and self.useFortranKernels: 859d310bb7SBarry Smith raise RuntimeError('Cannot use fortran kernels without a Fortran compiler') 869d310bb7SBarry Smith if self.useFortranKernels: 879d310bb7SBarry Smith self.addDefine('USE_FORTRAN_KERNELS', 1) 889d310bb7SBarry Smith if self.libraries.isBGL(): 899d310bb7SBarry Smith self.addDefine('AssertAlignx(a,b)','call ALIGNX(a,b)') 909d310bb7SBarry Smith else: 919d310bb7SBarry Smith self.addDefine('AssertAlignx(a,b)',' ') 929d310bb7SBarry Smith 93ef4c6e81SRichard Tran Mills self.useAVX512Kernels = self.framework.argDB['with-avx512-kernels'] 94ef4c6e81SRichard Tran Mills if self.useAVX512Kernels: 95ef4c6e81SRichard Tran Mills self.addDefine('USE_AVX512_KERNELS', 1) 969d310bb7SBarry Smith return 979d310bb7SBarry Smith 989d310bb7SBarry Smith def configureISColorValueType(self): 99569ea7c4SPierre Jolivet '''Sets PETSC_IS_COLORING_VALUE_TYPE, PETSC_MPIU_IS_COLORING_VALUE_TYPE, and PETSC_IS_COLORING_MAX as required by ISColoring''' 1009d310bb7SBarry Smith self.isColorValueType = self.framework.argDB['with-is-color-value-type'] 1019d310bb7SBarry Smith if self.isColorValueType != 'char' and self.isColorValueType != 'short': 1029d310bb7SBarry Smith raise RuntimeError('Incorrect --with-is-color-value-type value specified. Can be either char or short. Specified value is :'+self.isColorValueType) 1039d310bb7SBarry Smith if self.isColorValueType == 'char': 10415a5570dSLisandro Dalcin max_value = 'UCHAR_MAX' 1059d310bb7SBarry Smith mpi_type = 'MPI_UNSIGNED_CHAR' 1066564ec32SJed Brown type_f = 'integer1' 1079d310bb7SBarry Smith else: 10815a5570dSLisandro Dalcin max_value = 'USHRT_MAX' 1099d310bb7SBarry Smith mpi_type = 'MPI_UNSIGNED_SHORT' 1106564ec32SJed Brown type_f = 'integer2' 1119d310bb7SBarry Smith 112569ea7c4SPierre Jolivet self.addDefine('MPIU_IS_COLORING_VALUE_TYPE',mpi_type) 113569ea7c4SPierre Jolivet self.addDefine('IS_COLORING_MAX',max_value) 114569ea7c4SPierre Jolivet self.addDefine('IS_COLORING_VALUE_TYPE',self.isColorValueType) 115569ea7c4SPierre Jolivet self.addDefine('IS_COLORING_VALUE_TYPE_F',type_f) 1169d310bb7SBarry Smith return 1179d310bb7SBarry Smith 1189d310bb7SBarry Smith def configure(self): 1199d310bb7SBarry Smith self.executeTest(self.configureLibraryOptions) 1209d310bb7SBarry Smith self.executeTest(self.configureISColorValueType) 1219d310bb7SBarry Smith return 122