New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize Targets as Operators #1028
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0741fc6
targets: Refactor Target __init__
FabioLuporini c53cd79
targets: passes.py -> misc.py
FabioLuporini b1212ae
operator: Refactor lowering methods
FabioLuporini ab17d9e
Generalize Targets as Operators [pass 0]
FabioLuporini 61c1487
Generalize Targets as Operators [pass 1]
FabioLuporini 2cb0135
Generalize Targets as Operators [pass 2]
FabioLuporini 7a743d3
Generalize Targets as Operators [pass 3]
FabioLuporini b817978
Generalize Targets as Operators [pass 4]
FabioLuporini 41ab3bd
yask: Yask -> YASK all over the place
FabioLuporini 77b7c50
target_pass -> iet_pass
FabioLuporini d68ca3c
tests: Drop some dle=noop so that YASK behaves
FabioLuporini c73ca8f
passes: Flush denormals once, not in each efunc
FabioLuporini 82a4304
Fixup docstring
FabioLuporini 1c09e0b
yask: Fixup noop operators
FabioLuporini 6a31820
Clean up: whitespaces, import ordering, docstrings ...
FabioLuporini e33e6a3
Fixup comments and docstrings
FabioLuporini File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
from functools import partial | ||
|
||
from devito.core.operator import OperatorCore | ||
from devito.exceptions import InvalidOperator | ||
from devito.passes import (DataManager, Blocker, Ompizer, avoid_denormals, | ||
optimize_halospots, mpiize, loop_wrapping, | ||
minimize_remainders, hoist_prodders) | ||
from devito.tools import as_tuple | ||
|
||
__all__ = ['CPU64NoopOperator', 'CPU64Operator', 'Intel64Operator', 'PowerOperator', | ||
'ArmOperator', 'CustomOperator'] | ||
|
||
|
||
class CPU64NoopOperator(OperatorCore): | ||
|
||
@classmethod | ||
def _specialize_iet(cls, graph, **kwargs): | ||
# Symbol definitions | ||
data_manager = DataManager() | ||
data_manager.place_definitions(graph) | ||
data_manager.place_casts(graph) | ||
|
||
return graph | ||
|
||
|
||
class CPU64Operator(CPU64NoopOperator): | ||
|
||
BLOCK_LEVELS = 1 | ||
""" | ||
Loop blocking depth. So, 1 => "blocks", 2 => "blocks" and "sub-blocks", | ||
3 => "blocks", "sub-blocks", and "sub-sub-blocks", ... | ||
""" | ||
|
||
@classmethod | ||
def _specialize_iet(cls, graph, **kwargs): | ||
options = kwargs['options'] | ||
platform = kwargs['platform'] | ||
|
||
# Flush denormal numbers | ||
avoid_denormals(graph) | ||
|
||
# Distributed-memory parallelism | ||
optimize_halospots(graph) | ||
if options['mpi']: | ||
mpiize(graph, mode=options['mpi']) | ||
|
||
# Tiling | ||
blocker = Blocker(options['blockinner'], | ||
options['blocklevels'] or cls.BLOCK_LEVELS) | ||
blocker.make_blocking(graph) | ||
|
||
# Shared-memory and SIMD-level parallelism | ||
ompizer = Ompizer() | ||
ompizer.make_simd(graph, simd_reg_size=platform.simd_reg_size) | ||
if options['openmp']: | ||
ompizer.make_parallel(graph) | ||
|
||
# Misc optimizations | ||
minimize_remainders(graph, simd_items_per_reg=platform.simd_items_per_reg) | ||
hoist_prodders(graph) | ||
|
||
# Symbol definitions | ||
data_manager = DataManager() | ||
data_manager.place_definitions(graph) | ||
data_manager.place_casts(graph) | ||
|
||
return graph | ||
|
||
|
||
Intel64Operator = CPU64Operator | ||
PowerOperator = CPU64Operator | ||
ArmOperator = CPU64Operator | ||
|
||
|
||
class CustomOperator(CPU64Operator): | ||
|
||
@classmethod | ||
def _make_passes_mapper(cls, **kwargs): | ||
options = kwargs['options'] | ||
platform = kwargs['platform'] | ||
|
||
blocker = Blocker(options['blockinner'], | ||
options['blocklevels'] or cls.BLOCK_LEVELS) | ||
|
||
ompizer = Ompizer() | ||
|
||
return { | ||
'denormals': partial(avoid_denormals), | ||
'optcomms': partial(optimize_halospots), | ||
'wrapping': partial(loop_wrapping), | ||
'blocking': partial(blocker.make_blocking), | ||
'openmp': partial(ompizer.make_parallel), | ||
'mpi': partial(mpiize, mode=options['mpi']), | ||
'simd': partial(ompizer.make_simd, simd_reg_size=platform.simd_reg_size), | ||
'minrem': partial(minimize_remainders, | ||
simd_items_per_reg=platform.simd_items_per_reg), | ||
'prodders': partial(hoist_prodders) | ||
} | ||
|
||
@classmethod | ||
def _specialize_iet(cls, graph, **kwargs): | ||
options = kwargs['options'] | ||
passes = as_tuple(kwargs['mode']) | ||
|
||
# Fetch passes to be called | ||
passes_mapper = cls._make_passes_mapper(**kwargs) | ||
|
||
# Call passes | ||
for i in passes: | ||
try: | ||
passes_mapper[i](graph) | ||
except KeyError: | ||
raise InvalidOperator("Unknown passes `%s`" % str(passes)) | ||
|
||
# Force-call `mpi` if requested via global option | ||
if 'mpi' not in passes and options['mpi']: | ||
passes_mapper['mpi'](graph) | ||
|
||
# Force-call `openmp` if requested via global option | ||
if 'openmp' not in passes and options['openmp']: | ||
passes_mapper['openmp'](graph) | ||
|
||
# Symbol definitions | ||
data_manager = DataManager() | ||
data_manager.place_definitions(graph) | ||
data_manager.place_casts(graph) | ||
|
||
return graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .operator import Operator # noqa | ||
from .profiling import profiler_registry # noqa | ||
from .registry import operator_registry # noqa |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For mpi sure, but this one is by default to using it so maybe shouldn't if not asked for in the custom options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm just replicating master's behavior ?
we only end up here when dle != noop/advanced , eg
all the code is doing is that if 'openmp' doesn't appear among X above, then it depends on the value of DEVITO_OPENMP (which is encoded in
options['openmp']
)