Skip to content
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

orchestrator fix: keep exchange object optional #570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions model/common/src/icon4py/model/common/orchestration/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@


@overload
def orchestrate(func: Callable[P, R], *, method: bool | None = None) -> Callable[P, R]:
...
def orchestrate(func: Callable[P, R], *, method: bool | None = None) -> Callable[P, R]: ...


@overload
def orchestrate(
func: None = None, *, method: bool | None = None
) -> Callable[[Callable[P, R]], Callable[P, R]]:
...
) -> Callable[[Callable[P, R]], Callable[P, R]]: ...


def orchestrate(
Expand Down Expand Up @@ -539,35 +537,37 @@ def dace_specific_kwargs(

The additional kwargs are the connectivity tables (runtime tables) and the GHEX C++ pointers.
"""
return {
dace_kwargs = {
# connectivity tables at runtime
**{
connectivity_identifier(k): v.table
for k, v in offset_providers.items()
if hasattr(v, "table")
},
# GHEX C++ ptrs
"__context_ptr": expose_cpp_ptr(exchange_obj._context)
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0,
"__comm_ptr": expose_cpp_ptr(exchange_obj._comm)
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0,
**{
f"__pattern_{dim.value}Dim_ptr": expose_cpp_ptr(exchange_obj._patterns[dim])
connectivity_identifier(k): v.table
for k, v in offset_providers.items()
if hasattr(v, "table")
}
if exchange_obj:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to set all these keys to the default value (0)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would favour the if exchange_obj is not None and not isinstance(exchange_obj, decomposition.SingleNodeExchange) and set the pointers to 0.

dace_kwargs |= {
# GHEX C++ ptrs
"__context_ptr": expose_cpp_ptr(exchange_obj._context)
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0
for dim in dims.global_dimensions.values()
},
**{
f"__domain_descriptor_{dim.value}Dim_ptr": expose_cpp_ptr(
exchange_obj._domain_descriptors[dim].__wrapped__
)
else 0,
"__comm_ptr": expose_cpp_ptr(exchange_obj._comm)
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0
for dim in dims.global_dimensions.values()
},
}
else 0,
**{
f"__pattern_{dim.value}Dim_ptr": expose_cpp_ptr(exchange_obj._patterns[dim])
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0
for dim in dims.global_dimensions.values()
},
**{
f"__domain_descriptor_{dim.value}Dim_ptr": expose_cpp_ptr(
exchange_obj._domain_descriptors[dim].__wrapped__
)
if not isinstance(exchange_obj, decomposition.SingleNodeExchange)
else 0
for dim in dims.global_dimensions.values()
},
}
return dace_kwargs

def modified_orig_annotations(
dace_annotations: dict[str, Any], fuse_func_orig_annotations: dict[str, Any]
Expand Down
Loading