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