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

Remove unnecessary broadcast type #2207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

charleskawczynski
Copy link
Member

It looks like we have two stencil styles, that from what I can tell have no reason to be different: a StencilStyle and a ColumnStencilStyle. For some reason, StencilStyle is used in result_style in broadcasted, and ColumnStencilStyle is used elsewhere.

I ran into an issue:

ERROR: LoadError: conflicting broadcast rules defined
  Broadcast.BroadcastStyle(::ClimaCore.Operators.StencilStyle, ::ClimaCore.Operators.ColumnStencilStyle) = ClimaCore.Operators.StencilStyle()
  Broadcast.BroadcastStyle(::ClimaCore.Operators.ColumnStencilStyle, ::ClimaCore.Operators.StencilStyle) = ClimaCore.Operators.ColumnStencilStyle()
One of these should be undefined (and thus return Broadcast.Unknown).
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] 
    @ Base.Broadcast ./broadcast.jl:474
  [3] result_style(s1::ClimaCore.Operators.StencilStyle, s2::ClimaCore.Operators.ColumnStencilStyle)
    @ Base.Broadcast ./broadcast.jl:457
  [4] broadcasted(op::ClimaCore.Operators.GradientC2F{…}, args::Base.Broadcast.Broadcasted{…})
    @ ClimaCore.Operators ~/.julia/packages/ClimaCore/7GN1g/src/Operators/finitedifference.jl:3960

in a development branch. I think this change fixes this issue.

It looks like these were introduced in these two commits (from a while ago)

@charleskawczynski charleskawczynski force-pushed the ck/unify_stencil_styles branch from d0e9a70 to cd04087 Compare March 4, 2025 21:25
@charleskawczynski
Copy link
Member Author

I have one more piece to add to this:

Base.Broadcast.result_style(x::Operators.ColumnStencilStyle, y::CUDAColumnStencilStyle) = y
Base.Broadcast.BroadcastStyle(
    x::Operators.ColumnStencilStyle,
    y::CUDAColumnStencilStyle,
) = y

in the cuda ext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant