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

Halo construction #540

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f4633bd
transfer functionality from notebook (1).
halungge Jul 3, 2024
38299d9
add tests against simple grid
halungge Jul 5, 2024
ab696bb
pre-commit fixes
halungge Jul 5, 2024
3ff8191
test for uniqueness of owned indices
halungge Jul 5, 2024
a376211
merge main
halungge Jul 9, 2024
36d120e
local connectivities WIP (1)
halungge Jul 9, 2024
0df329d
add construction of local connectivities
halungge Jul 10, 2024
bd16dc9
WIP: test decomposition (1)
halungge Jul 11, 2024
c61a61e
Merge branch 'main' into halo_construction
halungge Jul 23, 2024
810e184
add distribute and gather test case (1)
halungge Jul 24, 2024
67192f4
add distribute and gather test case (2)
halungge Jul 24, 2024
9b4b08f
remove xugrid dependency
halungge Jul 26, 2024
fb49539
fix dtype issue in gather field tests
halungge Jul 26, 2024
2a01583
rename IndexTransformation implementation
halungge Jul 26, 2024
63ecbef
grid_manger clean up
halungge Jul 26, 2024
d70a034
rename global dimension mapping
halungge Jul 26, 2024
dc32f62
fix imports in test_grid_manager.py
halungge Jul 26, 2024
639f21d
change halo constructor interface: pass connectivity list instead of …
halungge Jul 26, 2024
6a1cd8c
move construction of local connectivity to grid_manager.py
halungge Jul 26, 2024
a6c94b7
WIP
halungge Jul 26, 2024
81e35b3
refactor grid_manger to construct local grids WIP(1)
halungge Jul 30, 2024
ac8009a
Merge branch 'main' into halo_construction
halungge Jul 30, 2024
c601aed
Merge branch 'main' into halo_construction
halungge Jul 30, 2024
696203f
refactor grid manager
halungge Aug 6, 2024
276db9d
halo levels for edges in test data (simple distribution)
halungge Aug 7, 2024
b8c6cc0
inject decomposer
halungge Aug 7, 2024
31b660f
compute vertex halos before edges
halungge Aug 7, 2024
b24613c
add halo level tests for edges
halungge Aug 7, 2024
9c134ed
add decomposition info to grid manager
halungge Aug 13, 2024
cedf717
add decomposition info to grid manager
halungge Aug 13, 2024
cf2bd56
Merge branch 'main' into halo_construction
halungge Aug 14, 2024
7f4a196
merge main
halungge Aug 28, 2024
f64e267
Merge branch 'main' into halo_construction
halungge Aug 29, 2024
4a2effd
rename global_dims to horizontal_dims
halungge Aug 29, 2024
59d813a
start/end index (WIP)
halungge Aug 30, 2024
a129138
start / end indices (WIP) add refinement.py
halungge Sep 3, 2024
d303d90
merge main
halungge Sep 3, 2024
82c2cf5
compute start end indices for Zones: local, halos
halungge Sep 4, 2024
2ef989d
refactor: grid manager
halungge Sep 4, 2024
73091d7
add boundary zones to test
halungge Sep 4, 2024
02950be
Merge branch 'main' into halo_construction
halungge Sep 4, 2024
6095199
use GridFile as content manager in grid_manager
halungge Sep 5, 2024
a2d3d5e
make GridManager implement context manager
halungge Sep 5, 2024
51bc2cd
get dummy parallel test_parallel_grid_manager.py to run
halungge Sep 6, 2024
ebad859
Merge branch 'main' into halo_construction
halungge Sep 6, 2024
5d9a331
add data URI for parallel APE R02B04 experiment
halungge Sep 6, 2024
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
4 changes: 3 additions & 1 deletion model/common/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ requires-python = ">=3.10"

[project.optional-dependencies]
all = ["icon4py-common[ghex,io]"]
ghex = ["ghex", "mpi4py"]
ghex = ["ghex", "mpi4py>=3.1.4", "pymetis>2022.1"]
io = [
"icon4py-common[netcdf]",
"xarray[complete]>=2024.3.0",
Expand Down Expand Up @@ -85,9 +85,11 @@ warn_unused_configs = true
warn_unused_ignores = true

[tool.pytest]
log_cli = true

[tool.pytest.ini_options]
addopts = ['-p icon4py.model.common.test_utils.pytest_config']
log_cli = true
markers = [
"datatest: test depending on serialized data generated by a full model run",
"with_netcdf: test depending on a compatible version of netCDF4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import enum
import functools
import logging
from dataclasses import dataclass
Expand All @@ -18,6 +19,7 @@
import numpy.ma as ma
from gt4py.next import Dimension

from icon4py.model.common.settings import xp
from icon4py.model.common.utils import builder


Expand All @@ -30,6 +32,9 @@ class ProcessProperties(Protocol):
comm_name: str
comm_size: int

def single_node(self) -> bool:
return self.comm_size == 1


@dataclass(frozen=True, init=False)
class SingleNodeProcessProperties(ProcessProperties):
Expand Down Expand Up @@ -67,12 +72,20 @@ class EntryType(IntEnum):
HALO = 2

@builder.builder
def with_dimension(self, dim: Dimension, global_index: np.ndarray, owner_mask: np.ndarray):
def with_dimension(
self,
dim: Dimension,
global_index: np.ndarray,
owner_mask: np.ndarray,
halo_levels: np.ndarray,
):
masked_global_index = ma.array(global_index, mask=owner_mask)
self._global_index[dim] = masked_global_index
self._halo_levels[dim] = halo_levels

def __init__(self, klevels: int):
self._global_index = {}
self._halo_levels = {}
self._klevels = klevels

@property
Expand Down Expand Up @@ -113,6 +126,12 @@ def global_index(self, dim: Dimension, entry_type: EntryType = EntryType.ALL):
case _:
raise NotImplementedError()

def halo_levels(self, dim: Dimension):
return self._halo_levels[dim]

def halo_level_mask(self, dim: Dimension, level: DecompositionFlag):
return xp.where(self._halo_levels[dim] == level, True, False)


class ExchangeResult(Protocol):
def wait(self):
Expand Down Expand Up @@ -225,3 +244,34 @@ def create_single_node_exchange(
props: SingleNodeProcessProperties, decomp_info: DecompositionInfo
) -> ExchangeRuntime:
return SingleNodeExchange()


class DecompositionFlag(enum.IntEnum):
UNDEFINED = -1
OWNED = 0
"""used for locally owned cells, vertices, edges"""

FIRST_HALO_LINE = 1
"""
used for:
- cells that share 1 edge with an OWNED cell
- vertices that are on OWNED cell
- edges that are on OWNED cell
"""

SECOND_HALO_LINE = 2
"""
used for:
- cells that share a vertex with an OWNED cell
- vertices that are on a cell(FIRST_HALO_LINE) but not on an owned cell
- edges that have _exactly_ one vertex shared with and OWNED Cell
"""

THIRD_HALO_LINE = 3
"""
This type does not exist in ICON. It denotes the "closing/far" edges of the SECOND_HALO_LINE cells
used for:
- cells (NOT USED)
- vertices (NOT USED)
- edges that are only on the cell(SECOND_HALO_LINE)
"""
Loading
Loading