1#!/usr/bin/env python 2from __future__ import generators 3import config.base 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 __str1__(self): 13 if not hasattr(self, 'memalign'): 14 return '' 15 return ' Memory alignment from malloc(): ' + self.memalign + ' bytes\n' 16 17 def setupHelp(self, help): 18 import nargs 19 help.addArgument('PETSc', '-with-memalign=<4,8,16,32,64>', nargs.Arg(None, '16', 'Specify alignment of arrays allocated by PETSc')) 20 return 21 22 def setupDependencies(self, framework): 23 config.base.Configure.setupDependencies(self, framework) 24 self.types = framework.require('config.types', self) 25 self.languages = framework.require('PETSc.options.languages', self) 26 self.compilers = framework.require('config.compilers', self) 27 return 28 29 def configureMemAlign(self): 30 '''Choose alignment''' 31 # 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. 32 valid = ['4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192'] 33 self.memalign = self.framework.argDB['with-memalign'] 34 if self.memalign in valid: 35 self.addDefine('MEMALIGN', self.memalign) 36 else: 37 raise RuntimeError('--with-memalign must be in' + str(valid)) 38 self.logPrint('Memory alignment is ' + self.memalign) 39 return 40 41 def configure(self): 42 self.executeTest(self.configureMemAlign) 43 return 44