File: memAlign.py

package info (click to toggle)
petsc 3.23.1%2Bdfsg1-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 515,576 kB
  • sloc: ansic: 751,607; cpp: 51,542; python: 38,598; f90: 17,352; javascript: 3,493; makefile: 3,157; sh: 1,502; xml: 619; objc: 445; java: 13; csh: 1
file content (42 lines) | stat: -rwxr-xr-x 1,572 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import generators
import config.base

class Configure(config.base.Configure):
  def __init__(self, framework):
    config.base.Configure.__init__(self, framework)
    self.headerPrefix = ''
    self.substPrefix  = ''
    return

  def __str1__(self):
    if not hasattr(self, 'memalign'):
      return ''
    return '  Memory alignment from malloc(): ' + self.memalign + ' bytes\n'

  def setupHelp(self, help):
    import nargs
    help.addArgument('PETSc', '-with-memalign=<4,8,16,32,64>', nargs.Arg(None, '16', 'Specify alignment of arrays allocated by PETSc'))
    return

  def setupDependencies(self, framework):
    config.base.Configure.setupDependencies(self, framework)
    self.types     = framework.require('config.types', self)
    self.languages = framework.require('PETSc.options.languages', self)
    self.compilers = framework.require('config.compilers', self)
    return

  def configureMemAlign(self):
    '''Choose memory alignment'''
    # 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.
    valid = ['4', '8', '16', '32', '64', '128', '256', '512', '1024', '2048', '4096', '8192']
    self.memalign = self.framework.argDB['with-memalign']
    if self.memalign in valid:
      self.addDefine('MEMALIGN', self.memalign)
    else:
      raise RuntimeError('--with-memalign must be in' + str(valid))
    self.logPrint('Memory alignment is ' + self.memalign)
    return

  def configure(self):
    self.executeTest(self.configureMemAlign)
    return