-
Notifications
You must be signed in to change notification settings - Fork 11
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
[NASA:Update] Distributed dace cache (rework) #16
Changes from 65 commits
6d78659
0a3e857
0a8d705
3b73d71
a68d160
33ba53f
8968698
2327cbe
cb4ec5f
7348922
e234d16
131a2af
dce3fb7
8982542
da2f902
f2799d8
27fae1c
2f8ebac
5d9e0a0
b8edbf2
f54b231
81d00ce
4891d56
fafbfc7
4fc5b4d
2245027
4f8fdc3
47421a0
d51bc11
6bdd595
80cbb01
40f2440
cae25a9
915993e
c3e355c
08f6e68
cde11e8
9e6bbb6
6695cec
7e449cd
e40d356
286ad00
fea7ae6
c1e011c
c58a2a1
8e362a2
adc5ee5
a306e66
39ff8ea
f2d171d
ac70398
0a4163f
e1f8a94
9d6d2f9
2031b9e
b579437
52f0913
2f9bbe9
8f6ba7c
31c4844
08f3033
d63a0f0
6de1b3c
33ac533
7955695
1252736
8de32bc
6ef8b60
51fca6e
132e2c4
689f4b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from pace.dsl.caches.codepath import FV3CodePath | ||
from pace.util import CubedSpherePartitioner | ||
|
||
|
||
def identify_code_path( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something about this feels awkward to me, but I'm not sure making this live inside of a more fully-featured FV3CodePath class makes sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a proper build class/system that uproots most of all of this and consolidate it to one place. It should include distributed compiling for non-orchestrated backend, better hash/cache and much more. I went for a functional paradigm in the meantime, since I fully expect this to be reworked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I don't have a super compelling alternative and it's not really blocking, just felt awkward when I read it |
||
rank: int, | ||
partitioner: CubedSpherePartitioner, | ||
) -> FV3CodePath: | ||
if partitioner.layout == (1, 1) or partitioner.layout == [1, 1]: | ||
return FV3CodePath.All | ||
elif partitioner.layout[0] == 1 or partitioner.layout[1] == 1: | ||
raise NotImplementedError( | ||
f"Build for layout {partitioner.layout} is not handled" | ||
) | ||
else: | ||
if partitioner.tile.on_tile_bottom(rank): | ||
if partitioner.tile.on_tile_left(rank): | ||
return FV3CodePath.BottomLeft | ||
if partitioner.tile.on_tile_right(rank): | ||
return FV3CodePath.BottomRight | ||
else: | ||
return FV3CodePath.Bottom | ||
if partitioner.tile.on_tile_top(rank): | ||
if partitioner.tile.on_tile_left(rank): | ||
return FV3CodePath.TopLeft | ||
if partitioner.tile.on_tile_right(rank): | ||
return FV3CodePath.TopRight | ||
else: | ||
return FV3CodePath.Top | ||
else: | ||
if partitioner.tile.on_tile_left(rank): | ||
return FV3CodePath.Left | ||
if partitioner.tile.on_tile_right(rank): | ||
return FV3CodePath.Right | ||
else: | ||
return FV3CodePath.Center | ||
|
||
|
||
def get_cache_fullpath(code_path: FV3CodePath) -> str: | ||
from gt4py.cartesian import config as gt_config | ||
|
||
return f"{gt_config.cache_settings['root_path']}/.gt_cache_{code_path}" | ||
|
||
|
||
def get_cache_directory(code_path: FV3CodePath) -> str: | ||
return f".gt_cache_{code_path}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import enum | ||
|
||
|
||
class FV3CodePath(enum.Enum): | ||
"""Enum listing all possible code paths on a cube sphere. | ||
For any layout the cube sphere has up to 9 different code paths depending on | ||
the positioning of the rank on the tile and which of the edge/corner cases | ||
it has to handle, as well as the possibility for all boundary computations in | ||
the 1x1 layout case. | ||
Since the framework inlines code to optimize, we _cannot_ pre-suppose which code | ||
being kept and/or ejected. This enum serves as the ground truth to map rank to | ||
the proper generated code. | ||
""" | ||
|
||
All = "FV3_A" | ||
BottomLeft = "FV3_BL" | ||
Left = "FV3_L" | ||
TopLeft = "FV3_TL" | ||
Top = "FV3_T" | ||
TopRight = "FV3_TR" | ||
Right = "FV3_R" | ||
BottomRight = "FV3_BR" | ||
Bottom = "FV3_B" | ||
Center = "FV3_C" | ||
|
||
def __str__(self): | ||
return self.value | ||
|
||
def __repr__(self): | ||
return self.value | ||
|
||
def __format__(self, format_spec: str) -> str: | ||
return self.value |
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.
Why does it matter whether we use empty or zeros here? It seems like setting the memory to 0 is an unnecessary step. Also is there a better way to get at the backend than through a Quantity?
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.
This is too fix the "deterministic" test in utest. Empty grabs any memory. The fact is that test fails because halos have the wrong values and it gets pass down. Arguably I did a blanket cover of all the empty/zeros because non of them will be executed at realtime, so the small extra cost of zero-ing it out does not matter.