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

Overwritten get_contravariant_vectors leading to error #61

Closed
benegee opened this issue Jan 13, 2025 · 1 comment · Fixed by #62
Closed

Overwritten get_contravariant_vectors leading to error #61

benegee opened this issue Jan 13, 2025 · 1 comment · Fixed by #62
Labels
bug Something isn't working

Comments

@benegee
Copy link
Collaborator

benegee commented Jan 13, 2025

Currently some (all?) examples fail to run threaded.

E.g. julia -t 2 --project=. -e 'include("../examples/elixir_moist_euler_moist_bubble.jl")' leads to:

ERROR: LoadError: MethodError: no method matching static2val(::Int64)
The function `static2val` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  static2val(::Static.StaticInt{N}) where N
   @ TrixiAtmo ~/trixi/TrixiAtmo-vanilla.jl/src/solvers/dgsem_p4est/containers_2d_manifold_in_3d_cartesian.jl:48

Stacktrace:
  [1] get_contravariant_vector
    @ ~/trixi/TrixiAtmo-vanilla.jl/src/solvers/dgsem_p4est/containers_2d_manifold_in_3d_cartesian.jl:51 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/Trixi/6nxkA/src/callbacks_step/stepsize_dg2d.jl:97 [inlined]
...
  [8] max_dt ...
    @ Trixi ~/trixi/TrixiAtmo-vanilla.jl/run/dev/Trixi/src/callbacks_step/stepsize_dg2d.jl:93
  [9] calculate_dt
    @ ~/trixi/TrixiAtmo-vanilla.jl/run/dev/Trixi/src/callbacks_step/stepsize.jl:91 [inlined]
...

The reason is that @batch is used in max_dt (https://github.com/trixi-framework/Trixi.jl/blob/e93de2a5f5c9cab36e7593dc2fc7cdb8d216af48/src/callbacks_step/stepsize_dg2d.jl#L90), which turns Arrays into PtrArrays (https://github.com/JuliaSIMD/Polyester.jl?tab=readme-ov-file#important-notes). Thus, TrixiAtmo's get_contravariant_vectors

@inline function Trixi.get_contravariant_vector(index, contravariant_vectors::PtrArray,
is picked up.

Can we somehow refine the dispatching s.t. "usual" setups keep using Trixi's version?

@benegee benegee added the bug Something isn't working label Jan 13, 2025
@tristanmontoya
Copy link
Member

tristanmontoya commented Jan 13, 2025

Thanks for pointing this out. I get the same issue as you for the new equation sets that use the "standard" Trixi.jl solvers, but the Cartesian and covariant solvers for PDEs on surfaces still seem to work with threading. I'll have to look what the type parameters of PtrArray are, but we could potentially dispatch on one of them, or otherwise make the Cartesian solver for surfaces not use the get_contravariant_vector function at all (the latter approach would likely require repeating more of Trixi.jl's code in TrixiAtmo.jl, which would of course be undesirable).

Edit: I refined the dispatch in #62 and it seems to work, but perhaps someone more familiar with PtrArray can comment on whether what I did makes sense and/or suggest a better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants