19d310bb7SBarry Smithfrom __future__ import generators 29d310bb7SBarry Smithimport config.base 39d310bb7SBarry Smith 49d310bb7SBarry Smithclass Configure(config.base.Configure): 59d310bb7SBarry Smith def __init__(self, framework): 69d310bb7SBarry Smith config.base.Configure.__init__(self, framework) 79d310bb7SBarry Smith self.headerPrefix = '' 89d310bb7SBarry Smith self.substPrefix = '' 99d310bb7SBarry Smith return 109d310bb7SBarry Smith 119d310bb7SBarry Smith def __str1__(self): 129d310bb7SBarry Smith if not hasattr(self, 'memalign'): 139d310bb7SBarry Smith return '' 14a9acdec7SBarry Smith return ' Memory alignment from malloc(): ' + self.memalign + ' bytes\n' 159d310bb7SBarry Smith 169d310bb7SBarry Smith def setupHelp(self, help): 179d310bb7SBarry Smith import nargs 189d310bb7SBarry Smith help.addArgument('PETSc', '-with-memalign=<4,8,16,32,64>', nargs.Arg(None, '16', 'Specify alignment of arrays allocated by PETSc')) 199d310bb7SBarry Smith return 209d310bb7SBarry Smith 219d310bb7SBarry Smith def setupDependencies(self, framework): 229d310bb7SBarry Smith config.base.Configure.setupDependencies(self, framework) 239d310bb7SBarry Smith self.types = framework.require('config.types', self) 249d310bb7SBarry Smith self.languages = framework.require('PETSc.options.languages', self) 259d310bb7SBarry Smith self.compilers = framework.require('config.compilers', self) 269d310bb7SBarry Smith return 279d310bb7SBarry Smith 289d310bb7SBarry Smith def configureMemAlign(self): 29*7b65ca21SBarry Smith '''Choose memory alignment''' 309d310bb7SBarry Smith # Intel/AMD cache lines are 64 bytes, default page sizes are usually 4kB. It would be pretty silly to want that much alignment by default. 319d310bb7SBarry Smith valid = ['4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192'] 329d310bb7SBarry Smith self.memalign = self.framework.argDB['with-memalign'] 339d310bb7SBarry Smith if self.memalign in valid: 349d310bb7SBarry Smith self.addDefine('MEMALIGN', self.memalign) 359d310bb7SBarry Smith else: 369d310bb7SBarry Smith raise RuntimeError('--with-memalign must be in' + str(valid)) 377ad10985SMatthew G. Knepley self.logPrint('Memory alignment is ' + self.memalign) 389d310bb7SBarry Smith return 399d310bb7SBarry Smith 409d310bb7SBarry Smith def configure(self): 419d310bb7SBarry Smith self.executeTest(self.configureMemAlign) 429d310bb7SBarry Smith return 43