refactor[next-dace]: Add library node for reduce with skip values#2603
Conversation
4e1c0e5 to
308cfc7
Compare
|
cscs-ci run dace |
|
cscs-ci run default |
5fcb578 to
bf658c3
Compare
## Description Do not apply `open_mp` flags on device compilers - we don't do multithreading host code for GPU backends (and device is plain wrong). This flag usage was discovered in the case of an `icx/nvcc` where the `-qopenmp` intel flag bled into the command line of `nvcc`. ## Requirements - [ ] All fixes and/or new features come with corresponding tests. - [ ] Important design decisions have been documented in the appropriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/README.md) folder.
- Use same `dace` version for GT4Py cartesian and next. - Make `dace` a GT4Py dependency, and remove the development groups `dace-cartesian` and `dace-next`. - Instead of using the `gridtools` package index, pull the dace pre-release package from PyPI index. Note: if in the future a custom (non-pypi) version is needed, cartesian and next need to create a version from a common branch (and publish to the gridtools index).
b8f0627 to
14443e2
Compare
This reverts commit 7d769d6.
philip-paul-mueller
left a comment
There was a problem hiding this comment.
There are some small things but nothing big.
| wcr = dace_properties.LambdaProperty(default="lambda a, b: a") | ||
| identity = dace_properties.Property(default=0) | ||
| init = dace_properties.Property(default=0) |
There was a problem hiding this comment.
I think these properties should not have a default.
There was a problem hiding this comment.
I tried, but it is not allowed:
Error importing plugin "gt4py.next.type_system.mypy_plugin": Default not properly defined for property [misc]
By the way, the dace standard reduce does the same.
There was a problem hiding this comment.
Just a random question, did you specify a dtype value?
Looking at the error and Property::init() I would say that dtype is missing.
You can also play with allow_none.
There was a problem hiding this comment.
The problem is that dtype is not known. Yes, I could play with allow_none indeed.
| max_neighbors = mask_desc.shape[1] | ||
| assert isinstance(max_neighbors, int) or str(max_neighbors).isdigit() | ||
|
|
||
| local_dim_index = inedge.data.src_subset.size().index(max_neighbors) |
There was a problem hiding this comment.
Might break in cases where the number of {edges, cell, vertices} is the same as local dimensions.
Probably too paranoid and I do not have an alternative.
But you should probably put a TODO or NOTE here explaining what it is doing and what the problems are.
There was a problem hiding this comment.
I have an idea. I can check that the size of the subset is 1 in all dimensions except one, the local dimension. I will push a new commit.
There was a problem hiding this comment.
This should work (except for the case that there is only a single neighbour, which is probably unlikely).
philip-paul-mueller
left a comment
There was a problem hiding this comment.
Some small suggestions.
| wcr = dace_properties.LambdaProperty(default="lambda a, b: a") | ||
| identity = dace_properties.Property(default=0) | ||
| init = dace_properties.Property(default=0) |
There was a problem hiding this comment.
Just a random question, did you specify a dtype value?
Looking at the error and Property::init() I would say that dtype is missing.
You can also play with allow_none.
| max_neighbors = mask_desc.shape[1] | ||
| assert isinstance(max_neighbors, int) or str(max_neighbors).isdigit() | ||
|
|
||
| local_dim_index = inedge.data.src_subset.size().index(max_neighbors) |
There was a problem hiding this comment.
This should work (except for the case that there is only a single neighbour, which is probably unlikely).
|
|
||
| # We now expand all GT4Py specific library nodes. | ||
| # We do this such that we have control over all the Maps that are there. | ||
| # TODO(edopao,phimuell): It is probably the right place, but maybe there is a better one. |
There was a problem hiding this comment.
I am actually not sure if it is the best one.
I would maybe also think of moving it at the very end, however, given my experience with the broadcast node, we should probably keep it here for now.
| gtx_transformations.FuseHorizontalConditionBlocks(), | ||
| validate=True, | ||
| validate_all=True, | ||
| validate=False, |
DaCe has a library node in its standard library for reduction. However, GT4Py and ICON4Py also need to lower reduction expressions with skip values. The lowering was already done, on main, inside a nested SDFG. All this PR does is to refactor the code that creates the nested SDFG and make an application library node in GT4Py. In this way, the SDFG nodes for regular reduction and the nodes for reduction with skip values are represented in the same way in the SDFG.
No performance regression in ICON4Py blueline:
