Skip to content

Fix interpolate! on Metal for Float32 LatitudeLongitudeGrid - #6057

Merged
xkykai merged 1 commit into
mainfrom
xk/float32-longitude-range
Oct 1, 2026
Merged

xkykai merged 1 commit into
mainfrom
xk/float32-longitude-range

Conversation

@xkykai

@xkykai xkykai commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

find_λ_range uses floor(λ / 360) in place of the hand-built floor division ifelse((λ < 0) & (mod(λ, 360) != 0), λ ÷ 360 - 1, λ ÷ 360), so interpolate! compiles on Metal for Float32 LatitudeLongitudeGrids.

On Julia ≥ 1.12, ÷ and fld on Float32 go through Float64 (JuliaGPU/Metal.jl#972), which Metal can't compile. The upstream fix, JuliaGPU/Metal.jl#975, needs Metal ≥ 1.10.1, which needs GPUCompiler 2, and Enzyme and Reactant cap it at 1.x. floor(λ / 360) matches fld(λ, 360) for every Float32 with 2.5e-43 < |λ| < 1.9e8 on the CPU.

  • Adds a Metal test that interpolates between Float32 LatitudeLongitudeGrids with longitudes (-180, 180) and (0, 360).
  • A TODO at find_λ_range to switch to fld once Oceananigans can use a Metal release with the fix.

Closes #6056

🤖 Generated with Claude Code

xkykai added a commit that referenced this pull request Sep 22, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.84%. Comparing base (2429a6a) to head (efa542f).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6057      +/-   ##
==========================================
+ Coverage   74.83%   74.84%   +0.01%     
==========================================
  Files         439      439              
  Lines       27385    27382       -3     
==========================================
+ Hits        20493    20494       +1     
+ Misses       6892     6888       -4     
Flag Coverage Δ
buildkite 70.55% <100.00%> (+<0.01%) ⬆️
distributed_tripolar 20.55% <0.00%> (ø)
julia 70.55% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xkykai
xkykai marked this pull request as ready for review September 29, 2026 18:50
@xkykai
xkykai marked this pull request as draft September 29, 2026 18:59
@xkykai
xkykai marked this pull request as ready for review September 30, 2026 16:45
@xkykai
xkykai requested review from giordano and glwagner September 30, 2026 16:45
xkykai added a commit that referenced this pull request Sep 30, 2026
# Conflicts:
#	test/metal/metal.jl
@xkykai
xkykai added this pull request to stack #6122 September 30, 2026 17:45
Comment thread test/metal/metal.jl Outdated
xkykai added a commit that referenced this pull request Sep 30, 2026
@xkykai
xkykai requested a review from giordano September 30, 2026 21:23
@xkykai
xkykai force-pushed the xk/float32-longitude-range branch from db6578e to c9ba5c2 Compare September 30, 2026 21:27
xkykai added a commit that referenced this pull request Sep 30, 2026
`find_λ_range` uses `floor(λ / 360)`: on Julia ≥ 1.12, `÷` and `fld` on Float32
compile to Float64 instructions, which Metal rejects (JuliaGPU/Metal.jl#972).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xkykai
xkykai force-pushed the xk/float32-longitude-range branch from c9ba5c2 to efa542f Compare September 30, 2026 21:36
@xkykai
xkykai removed this pull request from stack #6122 September 30, 2026 21:37
@xkykai
xkykai merged commit fd14e72 into main Oct 1, 2026
15 of 16 checks passed
@xkykai
xkykai deleted the xk/float32-longitude-range branch October 1, 2026 04:31
xkykai added a commit that referenced this pull request Oct 5, 2026
#6015 and #6057 are on main; their files take main's version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interpolate! from a Float32 LatitudeLongitudeGrid fails on Metal: Float64 division in find_λ_range

2 participants