MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / guessMemoryLayout

Function guessMemoryLayout

generated_code/memlayout.py:98–124  ·  view source on GitHub ↗
(env)

Source from the content-addressed store, hash-verified

96 return candidates
97
98def guessMemoryLayout(env):
99 script_dir = os.path.dirname(os.path.abspath(__file__))
100 path = os.path.join(script_dir, '..', 'auto_tuning', 'config')
101
102 if 'gpu' in env['targets']:
103 print('INFO: Found gpu as a target. Memory layout will fall back to all dense')
104 return os.path.join(path, 'dense.xml')
105
106 # from least to most
107 importance = ['precision', 'equations', 'order', 'pe', 'multipleSimulations']
108 values = {
109 'precision': env['arch'][0].lower(),
110 'equations': env['equations'].lower(),
111 'order': int(env['order']),
112 'pe': arch.getCpu(env['arch']),
113 'multipleSimulations': int(env['multipleSimulations'])
114 }
115
116 candidates = findCandidates(search_path=path)
117 bestFit = max(candidates.keys(), key=lambda key: candidates[key].score(values))
118 bestScore = candidates[bestFit].score(values)
119
120 if bestScore == 0:
121 print('WARNING: No suitable memory layout found. (Will fall back to all dense.)')
122 bestFit = 'dense.xml'
123 print('Using memory layout {}'.format(bestFit))
124 return os.path.join(path, bestFit)

Callers

nothing calls this directly

Calls 3

printFunction · 0.85
findCandidatesFunction · 0.85
scoreMethod · 0.80

Tested by

no test coverage detected