コード例 #1
0
ファイル: MemoryLayout.py プロジェクト: m-ahsan-nazer/SeisSol
def getGlobalMatrices(order, arch):
  architecture = Arch.getArchitectureByIdentifier(arch)

  configs = {
    'kXiDivM': [ True ],
    'kEtaDivM': [ True ],
    'kZetaDivM': [ True ],
    'kXiDivMT': [ True ],
    'kEtaDivMT': [ True ],
    'kZetaDivMT': [ True ],
    'fM1': [ True ],
    'fM2': [ True ],
    'fP111': [ True ],
    'fP112': [ True ],
    'fP113': [ True ],
    'fP121': [ True ],
    'fP211': [ True ],
    'fP222': [ True ]
  }

  stiffnessMatrices = ['kXiDivM', 'kEtaDivM', 'kZetaDivM']
  transposedStiffnessBlocks = list()
  for o in range(2, order+1):
    stoprow = Tools.alignedNumberOfBasisFunctions(o-1, architecture)
    startcol = Tools.numberOfBasisFunctions(o-1)
    stopcol = Tools.numberOfBasisFunctions(o)
    transposedStiffnessBlocks.append((0, stoprow, startcol, stopcol))
  if len(transposedStiffnessBlocks) >= 2:
    # merge first two blocks
    block1 = transposedStiffnessBlocks.pop(0)
    block2 = transposedStiffnessBlocks.pop(0)
    mergedBlock = ( min(block1[0], block2[0]),
                    max(block1[1], block2[1]),
                    min(block1[2], block2[2]),
                    max(block1[3], block2[3]) )
    transposedStiffnessBlocks.insert(0, mergedBlock)

  stiffnessBlocks = [(block[2], block[3], block[0], block[1]) for block in transposedStiffnessBlocks]
  noMemsetStiffnessBlocks = list()
  for i, block in enumerate(stiffnessBlocks):
    startrow = noMemsetStiffnessBlocks[i-1][1] if i > 0 else block[0]
    stoprow = architecture.getAlignedIndex(block[1])
    noMemsetStiffnessBlocks.append( (startrow, stoprow, block[2], block[3]) )

  for matrix in stiffnessMatrices:
    configs[matrix].append(stiffnessBlocks)
    configs[matrix].append(noMemsetStiffnessBlocks)
    configs[matrix + 'T'].append(transposedStiffnessBlocks)
    
  return configs
コード例 #2
0
def getGlobalMatrices(order, arch):
    architecture = Arch.getArchitectureByIdentifier(arch)

    configs = {
        'kXiDivM': [True],
        'kEtaDivM': [True],
        'kZetaDivM': [True],
        'kXiDivMT': [True],
        'kEtaDivMT': [True],
        'kZetaDivMT': [True],
        'fM1': [True],
        'fM2': [True],
        'fP111': [True],
        'fP112': [True],
        'fP113': [True],
        'fP121': [True],
        'fP211': [True],
        'fP222': [True]
    }

    stiffnessMatrices = ['kXiDivM', 'kEtaDivM', 'kZetaDivM']
    transposedStiffnessBlocks = list()
    for o in range(2, order + 1):
        stoprow = Tools.alignedNumberOfBasisFunctions(o - 1, architecture)
        startcol = Tools.numberOfBasisFunctions(o - 1)
        stopcol = Tools.numberOfBasisFunctions(o)
        transposedStiffnessBlocks.append((0, stoprow, startcol, stopcol))
    if len(transposedStiffnessBlocks) >= 2:
        # merge first two blocks
        block1 = transposedStiffnessBlocks.pop(0)
        block2 = transposedStiffnessBlocks.pop(0)
        mergedBlock = (min(block1[0], block2[0]), max(block1[1], block2[1]),
                       min(block1[2], block2[2]), max(block1[3], block2[3]))
        transposedStiffnessBlocks.insert(0, mergedBlock)

    stiffnessBlocks = [(block[2], block[3], block[0], block[1])
                       for block in transposedStiffnessBlocks]
    noMemsetStiffnessBlocks = list()
    for i, block in enumerate(stiffnessBlocks):
        startrow = noMemsetStiffnessBlocks[i - 1][1] if i > 0 else block[0]
        stoprow = architecture.getAlignedIndex(block[1])
        noMemsetStiffnessBlocks.append((startrow, stoprow, block[2], block[3]))

    for matrix in stiffnessMatrices:
        configs[matrix].append(stiffnessBlocks)
        configs[matrix].append(noMemsetStiffnessBlocks)
        configs[matrix + 'T'].append(transposedStiffnessBlocks)

    return configs
コード例 #3
0
def getGlobalMatrices(order, arch):
    architecture = Arch.getArchitectureByIdentifier(arch)
    stiffnessMatrices = ['kXiDivM', 'kEtaDivM', 'kZetaDivM']
    groups = {'stiffnessTransposed': map(lambda x: x + 'T', stiffnessMatrices)}

    if architecture.name in ['knc', 'knl']:
        blockMerge = 2
        configs = {
            'kXiDivM': [],
            'kEtaDivM': [],
            'kZetaDivM': [],
            'stiffnessTransposed': [],
            'fP1': [],
            'fP2': [],
            'fP3': [],
            'r1DivM': [],
            'r2DivM': [],
            'r3DivM': [],
            'r4DivM': [],
            'rT1': [],
            'rT2': [],
            'rT3': [],
            'rT4': []
        }
    else:
        blockMerge = 1
        configs = {
            'kXiDivM': [True],
            'kEtaDivM': [True],
            'kZetaDivM': [True],
            'stiffnessTransposed': [True],
            'fP1': [True],
            'fP2': [True],
            'fP3': [True],
            'r1DivM': [True],
            'r2DivM': [True],
            'r3DivM': [True],
            'r4DivM': [True],
            'rT1': [True],
            'rT2': [True],
            'rT3': [True],
            'rT4': [True]
        }

    transposedStiffnessBlocks = list()
    for o in range(2, order + 1):
        stoprow = Tools.numberOfBasisFunctions(o - 1)
        startcol = Tools.numberOfBasisFunctions(o - 1)
        stopcol = Tools.numberOfBasisFunctions(o)
        transposedStiffnessBlocks.append((0, stoprow, startcol, stopcol))
    for i in range(blockMerge):
        if len(transposedStiffnessBlocks) >= 2:
            # merge first blocks
            block1 = transposedStiffnessBlocks.pop(0)
            block2 = transposedStiffnessBlocks.pop(0)
            transposedStiffnessBlocks.insert(0, mergeBlock(block1, block2))

    stiffnessBlocks = [(block[2], block[3], block[0], block[1])
                       for block in transposedStiffnessBlocks]
    noMemsetStiffnessBlocks = list()
    for i, block in enumerate(stiffnessBlocks):
        startrow = noMemsetStiffnessBlocks[i - 1][1] if i > 0 else block[0]
        stoprow = architecture.getAlignedIndex(
            block[1]) if i != len(stiffnessBlocks) - 1 else block[1]
        noMemsetStiffnessBlocks.append((startrow, stoprow, block[2], block[3]))

    for matrix in stiffnessMatrices:
        configs[matrix].append(stiffnessBlocks)
        configs[matrix].append(noMemsetStiffnessBlocks)

    if groups.has_key('stiffnessTransposed'):
        configs['stiffnessTransposed'].append(transposedStiffnessBlocks)
    else:
        for matrix in stiffnessMatrices:
            configs[matrix + 'T'].append(transposedStiffnessBlocks)

    # fP matrices
    fPBlocks = list()
    for o in range(1, order + 1):
        start = Tools.numberOfBasisFunctions2D(o - 1)
        stop = Tools.numberOfBasisFunctions2D(o)
        fPBlocks.append((start, stop, start, stop))
    # merge first three blocks
    for i in range(blockMerge + 1):
        if len(fPBlocks) >= 2:
            block1 = fPBlocks.pop(0)
            block2 = fPBlocks.pop(0)
            fPBlocks.insert(0, mergeBlock(block1, block2))
    for i in range(1, 4):
        configs['fP{}'.format(i)].append(fPBlocks)

    # rT matrices
    rTBlocks = list()
    for o in range(1, order + 1):
        stoprow = Tools.numberOfBasisFunctions2D(o)
        startcol = Tools.numberOfBasisFunctions(o - 1)
        stopcol = Tools.numberOfBasisFunctions(o)
        rTBlocks.append((0, stoprow, startcol, stopcol))
    # merge first three blocks
    for i in range(blockMerge + 1):
        if len(rTBlocks) >= 2:
            block1 = rTBlocks.pop(0)
            block2 = rTBlocks.pop(0)
            rTBlocks.insert(0, mergeBlock(block1, block2))
    rBlocks = [(block[2], block[3], block[0], block[1]) for block in rTBlocks]
    noMemsetRBlocks = list()
    for i, block in enumerate(rBlocks):
        startrow = noMemsetRBlocks[i - 1][1] if i > 0 else block[0]
        stoprow = architecture.getAlignedIndex(
            block[1]) if i != len(rBlocks) - 1 else block[1]
        noMemsetRBlocks.append((startrow, stoprow, block[2], block[3]))
    for i in range(1, 5):
        configs['r{}DivM'.format(i)].append(rBlocks)
        configs['r{}DivM'.format(i)].append(noMemsetRBlocks)
        configs['rT{}'.format(i)].append(rTBlocks)

    # fMrT and rT have the same sparsity pattern
    for i in range(1, 5):
        configs['fMrT{}'.format(i)] = copy.deepcopy(configs['rT{}'.format(i)])

    return (groups, configs)
コード例 #4
0
import Plasticity
import SurfaceDisplacement

cmdLineParser = argparse.ArgumentParser()
cmdLineParser.add_argument('--matricesDir')
cmdLineParser.add_argument('--outputDir')
cmdLineParser.add_argument('--arch')
cmdLineParser.add_argument('--order')
cmdLineParser.add_argument('--numberOfMechanisms')
cmdLineParser.add_argument('--generator')
cmdLineParser.add_argument('--memLayout')
cmdLineParser.add_argument('--dynamicRuptureMethod')
cmdLineParser.add_argument('--PlasticityMethod')
cmdLineArgs = cmdLineParser.parse_args()

architecture = Arch.getArchitectureByIdentifier(cmdLineArgs.arch)
libxsmmGenerator = cmdLineArgs.generator
order = int(cmdLineArgs.order)
numberOfMechanisms = int(cmdLineArgs.numberOfMechanisms)
numberOfBasisFunctions = Tools.numberOfBasisFunctions(order)
numberOfElasticQuantities = 9
numberOfMechanismQuantities = 6
numberOfReducedQuantities = numberOfElasticQuantities + numberOfMechanismQuantities
numberOfQuantities = numberOfElasticQuantities + 6*numberOfMechanisms

clones = {
  'star': [ 'AstarT', 'BstarT', 'CstarT' ]
}

# Load matrices
db = Tools.parseMatrixFile('{}/matrices_{}.xml'.format(cmdLineArgs.matricesDir, numberOfBasisFunctions), clones)
コード例 #5
0
ファイル: viscoelastic.py プロジェクト: SeisSol/SeisSol
from gemmgen import DB, Tools, Arch
import numpy as np
import argparse

cmdLineParser = argparse.ArgumentParser()
cmdLineParser.add_argument('--matricesDir')
cmdLineParser.add_argument('--outputDir')
cmdLineParser.add_argument('--arch')
cmdLineParser.add_argument('--order')
cmdLineParser.add_argument('--numberOfMechanisms')
cmdLineParser.add_argument('--generator')
cmdLineParser.add_argument('--memLayout')
cmdLineArgs = cmdLineParser.parse_args()

architecture = Arch.getArchitectureByIdentifier(cmdLineArgs.arch)
libxsmmGenerator = cmdLineArgs.generator
order = int(cmdLineArgs.order)
numberOfMechanisms = int(cmdLineArgs.numberOfMechanisms)
numberOfBasisFunctions = Tools.numberOfBasisFunctions(order)
numberOfQuantities = 9 + 6*numberOfMechanisms

clones = {
  'star': [ 'AstarT', 'BstarT', 'CstarT' ]
}

# Load matrices
db = Tools.parseMatrixFile('{}/matrices_{}.xml'.format(cmdLineArgs.matricesDir, numberOfBasisFunctions), clones)
db.update(Tools.parseMatrixFile('{}/matrices_viscoelastic.xml'.format(cmdLineArgs.matricesDir), clones))

# Determine sparsity patterns that depend on the number of mechanisms
コード例 #6
0
ファイル: MemoryLayout.py プロジェクト: SeisSol/SeisSol
def getGlobalMatrices(order, arch):
  architecture = Arch.getArchitectureByIdentifier(arch)
  stiffnessMatrices = ['kXiDivM', 'kEtaDivM', 'kZetaDivM']
  groups = {
    'stiffnessTransposed': map(lambda x: x + 'T', stiffnessMatrices)
  }

  if architecture.name in ['knc', 'knl']:
    blockMerge = 2
    configs = {
      'kXiDivM': [],
      'kEtaDivM': [],
      'kZetaDivM': [],
      'stiffnessTransposed': [],
      'fP1': [ ],
      'fP2': [ ],
      'fP3': [ ],
      'r1DivM': [ ],
      'r2DivM': [ ],
      'r3DivM': [ ],
      'r4DivM': [ ],
      'rT1': [ ],
      'rT2': [ ],
      'rT3': [ ],
      'rT4': [ ]
    }
  else:
    blockMerge = 1
    configs = {
      'kXiDivM': [ True ],
      'kEtaDivM': [ True ],
      'kZetaDivM': [ True ],
      'stiffnessTransposed': [ True ],
      'fP1': [ True ],
      'fP2': [ True ],
      'fP3': [ True ],
      'r1DivM': [ True ],
      'r2DivM': [ True ],
      'r3DivM': [ True ],
      'r4DivM': [ True ],
      'rT1': [ True ],
      'rT2': [ True ],
      'rT3': [ True ],
      'rT4': [ True ]
    }

  """
  transposedStiffnessBlocks = list()
  for o in range(2, order+1):
    stoprow = Tools.numberOfBasisFunctions(o-1)
    startcol = Tools.numberOfBasisFunctions(o-1)
    stopcol = Tools.numberOfBasisFunctions(o)
    transposedStiffnessBlocks.append((0, stoprow, startcol, stopcol))
  for i in range(blockMerge):
    if len(transposedStiffnessBlocks) >= 2:
      # merge first blocks
      block1 = transposedStiffnessBlocks.pop(0)
      block2 = transposedStiffnessBlocks.pop(0)
      transposedStiffnessBlocks.insert(0, mergeBlock(block1, block2))

  stiffnessBlocks = [(block[2], block[3], block[0], block[1]) for block in transposedStiffnessBlocks]
  noMemsetStiffnessBlocks = list()
  for i, block in enumerate(stiffnessBlocks):
    startrow = noMemsetStiffnessBlocks[i-1][1] if i > 0 else block[0]
    stoprow = architecture.getAlignedIndex(block[1]) if i != len(stiffnessBlocks)-1 else block[1]
    noMemsetStiffnessBlocks.append( (startrow, stoprow, block[2], block[3]) )

  for matrix in stiffnessMatrices:
    configs[matrix].append(stiffnessBlocks)
    configs[matrix].append(noMemsetStiffnessBlocks)

  if groups.has_key('stiffnessTransposed'):
    configs['stiffnessTransposed'].append(transposedStiffnessBlocks)
  else:
    for matrix in stiffnessMatrices:
      configs[matrix + 'T'].append(transposedStiffnessBlocks)
    
  # fP matrices
  fPBlocks = list()
  for o in range(1, order+1):
    start = Tools.numberOfBasisFunctions2D(o-1)
    stop = Tools.numberOfBasisFunctions2D(o)
    fPBlocks.append((start, stop, start, stop))
  # merge first three blocks
  for i in range(blockMerge+1):
    if len(fPBlocks) >= 2:
      block1 = fPBlocks.pop(0)
      block2 = fPBlocks.pop(0)
      fPBlocks.insert(0, mergeBlock(block1, block2))
  for i in range(1,4):
    configs['fP{}'.format(i)].append(fPBlocks)
  
  # rT matrices
  rTBlocks = list()
  for o in range(1, order+1):
    stoprow = Tools.numberOfBasisFunctions2D(o)
    startcol = Tools.numberOfBasisFunctions(o-1)
    stopcol = Tools.numberOfBasisFunctions(o)
    rTBlocks.append((0, stoprow, startcol, stopcol))    
  # merge first three blocks
  for i in range(blockMerge+1):
    if len(rTBlocks) >= 2:
      block1 = rTBlocks.pop(0)
      block2 = rTBlocks.pop(0)
      rTBlocks.insert(0, mergeBlock(block1, block2))
  rBlocks = [(block[2], block[3], block[0], block[1]) for block in rTBlocks]
  noMemsetRBlocks = list()
  for i, block in enumerate(rBlocks):
    startrow = noMemsetRBlocks[i-1][1] if i > 0 else block[0]
    stoprow = architecture.getAlignedIndex(block[1]) if i != len(rBlocks)-1 else block[1]
    noMemsetRBlocks.append( (startrow, stoprow, block[2], block[3]) )
  for i in range(1,5):
    configs['r{}DivM'.format(i)].append(rBlocks)
    configs['r{}DivM'.format(i)].append(noMemsetRBlocks)
    configs['rT{}'.format(i)].append(rTBlocks)
  """

  # fMrT and rT have the same sparsity pattern
  for i in range(1,5):
    configs['fMrT{}'.format(i)] = copy.deepcopy(configs['rT{}'.format(i)])
    
  return (groups, configs)