Skip to content

Switch to CBinding.jl v1.0 or Clang.jl #39

@ranocha

Description

@ranocha

Our current setup using CBindingGen will not work on Julia v1.7, see #37. Thus, we need to switch to CBinding.jl v1.0 or Clang.jl. However, neither option (CBinding.jl or Clang.jl) is perfect right now, as seen in #38 and discussed on Slack. Here is a summary of the current state.

Clang.jl

The new generator interface of Clang.jl looks promising. It basically creates Julia code to use the standard Julia interface for calling C code. However, it has some limitations such as

CBinding.jl v1.0

CBinding.jl provides another way of wrapping C code but doesn't use the Julia base C interface. This can make it more difficult to understand what's going on (e.g., trixi-framework/Trixi.jl#637 (comment)) but it might also be more intuitive sometimes. However, it doesn't work right now as we would like, see #38...

Patterns currently in use in Trixi.jl based on CBindingGen v0.9

Here is a list of the access patterns that we use in Trixi.jl at the moment.

  • p4est.connectivity
  • conn.num_trees
  • conn.num_vertices
  • unsafe_wrap(Array, conn.vertices, (3, n_vertices))
  • unsafe_wrap(Array, conn.tree_to_vertex, (2^NDIMS, n_trees))
  • Ptr{Int}(quadrant.p.user_data)
  • tree = unsafe_load_tree(info.p4est, info.treeid + 1)
  • tree.quadrants_offset
  • quad_id = offset + info.quadid
  • Ptr{Int}(info.quad.p.user_data)
  • quadrants = unsafe_wrap_sc(p4est_quadrant_t, trees[tree].quadrants)
  • quad.x, quad.y, quad.z
  • side.is_hanging
  • local_quad_id = side.is.full.quadid
  • info.sides.elem_count
  • sides[1].treeid
  • trees[1].quadrants_offset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions