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

Introduce OctaminimalGaussianArray; smaller, faster but less accurate #595

Merged
merged 9 commits into from
Oct 28, 2024

Conversation

milankl
Copy link
Member

@milankl milankl commented Oct 23, 2024

Motivated by #594 this reduces the number of grid points on the OctahedralGaussianGrid by starting at 4 points around the pole instead of 20. At nlat_half = 24, the default resolution, this yields 2400 grid points instead of 3168, i.e. -25%, hopefully making the parameterizations 25% faster, and the whole model by 12.5%-ish as parameterizations are currently more than 50% of total runtime.

Number of grid points per ring are (old, new)

julia> [(16+4i, 4i) for i in 1:24]
24-element Vector{Tuple{Int64, Int64}}:
 (20, 4)
 (24, 8)
 (28, 12)
 (32, 16)
 (36, 20)
 (40, 24)
 (44, 28)
 (48, 32)
 (52, 36)
 (56, 40)
 (60, 44)
 (64, 48)
 (68, 52)
 (72, 56)
 (76, 60)
 (80, 64)
 (84, 68)
 (88, 72)
 (92, 76)
 (96, 80)
 (100, 84)
 (104, 88)
 (108, 92)
 (112, 96)

@milankl milankl added performance 🚀 Faster faster! parameterizations 🌧️ Parameterizations of unresolved physical processes array types 🔢 LowerTriangularMatrices and RingGrids labels Oct 23, 2024
@milankl milankl changed the title Start OctahedralGaussianGrid with 4 points around pole Start octahedral grids with 4 points around pole Oct 23, 2024
@milankl milankl added grid 🌐 Points on a sphere and removed array types 🔢 LowerTriangularMatrices and RingGrids parameterizations 🌧️ Parameterizations of unresolved physical processes labels Oct 23, 2024
@milankl milankl changed the title Start octahedral grids with 4 points around pole Introduce OctaminimalGaussianArray, smaller, faster but less accurate Oct 25, 2024
@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

The "exact" tests with OctaminimalGaussianGrid pass once it's >T63 and single precision, at the moment the transform error is therefore only really present at low resolutions, see here

Test Summary:                              |   Pass  Fail   Total  Time
Transform: Individual Legendre polynomials | 665163   117  665280  7.6s
  trunc = 31                               |  33579    21   33600  0.7s
    NF = Float32                           |  16795     5   16800  0.3s
      Grid = FullGaussianGrid              |   3360          3360  0.1s
      Grid = FullClenshawGrid              |   3360          3360  0.0s
      Grid = OctahedralGaussianGrid        |   3360          3360  0.0s
      Grid = OctahedralClenshawGrid        |   3360          3360  0.0s
      Grid = OctaminimalGaussianGrid       |   3355     5    3360  0.1s
    NF = Float64                           |  16784    16   16800  0.4s
      Grid = FullGaussianGrid              |   3360          3360  0.1s
      Grid = FullClenshawGrid              |   3360          3360  0.0s
      Grid = OctahedralGaussianGrid        |   3360          3360  0.0s
      Grid = OctahedralClenshawGrid        |   3360          3360  0.0s
      Grid = OctaminimalGaussianGrid       |   3344    16    3360  0.2s
  trunc = 63                               | 128608    32  128640  1.5s
    NF = Float32                           |  64320         64320  0.6s
    NF = Float64                           |  64288    32   64320  0.9s
      Grid = FullGaussianGrid              |  12864         12864  0.1s
      Grid = FullClenshawGrid              |  12864         12864  0.1s
      Grid = OctahedralGaussianGrid        |  12864         12864  0.1s
      Grid = OctahedralClenshawGrid        |  12864         12864  0.1s
      Grid = OctaminimalGaussianGrid       |  12832    32   12864  0.5s
  trunc = 127                              | 502976    64  503040  5.4s
    NF = Float32                           | 251520        251520  2.1s
    NF = Float64                           | 251456    64  251520  3.3s
      Grid = FullGaussianGrid              |  50304         50304  0.4s
      Grid = FullClenshawGrid              |  50304         50304  0.8s
      Grid = OctahedralGaussianGrid        |  50304         50304  0.4s
      Grid = OctahedralClenshawGrid        |  50304         50304  0.4s
      Grid = OctaminimalGaussianGrid       |  50240    64   50304  1.3s

@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

Interpolation tests all pass once we switch to staggered longitudes, i.e. with an offset (not starting at 0˚E) as are also the HEALPix grids defined, first ring

  45.0
 135.0
 225.0
 315.0

second ring

  22.5
  67.5
 112.5
 157.5
 202.5
 247.5
 292.5
 337.5

etc

@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

Created a little comparison

image

moving to 4 points around the poles introduces weird grid cells around the poles because ECMWF defines Gaussian grids with 0 offset from prime meridian

image

with offset like HEALPix grids also use them that goes away

image

@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

So a candidate for a new default grid could be this one 2400 grid points, that's what I'd define as the OctaminimalGaussianGrid (octahedral Gaussian starting with 4 points, with offset)

image

vs a 24-ring octahedral Gaussian grid as ECMWF defines it, starting with 20 points, no offset, which has, however, 3168 grid points, i.e. +32%

image

@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

And one last

image

@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

No proper benchmarking here, but with the OctaminimalGaussianGrid I'm hitting some 700SYPD compared to 500-550SYPD on the octahedral Gaussian grid. Nice one 🚀

@milankl milankl changed the title Introduce OctaminimalGaussianArray, smaller, faster but less accurate Introduce OctaminimalGaussianArray; smaller, faster but less accurate Oct 28, 2024
@milankl milankl merged commit e85d45f into main Oct 28, 2024
5 checks passed
@milankl
Copy link
Member Author

milankl commented Oct 28, 2024

@hottad just merged, another grid in our grid zoo, the OctaminimalGaussianGrid, looks like the OctaHEALPixGrid, but uses Gaussian latitudes instead, haven't checked the error properly, but I suspect it's somewhere in between the exact grids and the healpix grids -- maybe a nice tradeoff. Definitely way more equal area than the OctahedralGaussianGrid!

@milankl milankl linked an issue Oct 28, 2024 that may be closed by this pull request
@milankl milankl deleted the mk/octahedral branch October 28, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grid 🌐 Points on a sphere performance 🚀 Faster faster!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Profiling of timestep
1 participant