Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
15 changes: 4 additions & 11 deletions .github/workflows/ci-jll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,18 @@ jobs:
matrix:
version:
- '1.9'
- 'lts'
- '1'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
24 changes: 8 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,18 @@ jobs:
matrix:
version:
- '1.9'
- 'lts'
- '1'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
#- uses: actions/cache@v1
# env:
# cache-name: cache-artifacts
# with:
# path: ~/.julia/artifacts
# key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
# restore-keys: |
# ${{ runner.os }}-test-${{ env.cache-name }}-
# ${{ runner.os }}-test-
# ${{ runner.os }}-
- name: Install p4est dependencies
run: |
sudo apt-get update
Expand Down Expand Up @@ -69,12 +61,12 @@ jobs:
using MPIPreferences
MPIPreferences.use_system_binary()

- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v6
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
# docs:
# name: Documentation
# runs-on: ubuntu-latest
Expand Down
43 changes: 24 additions & 19 deletions src/common_fixes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ const sc_array_t = sc_array
################################################################

function _pointer_to_c_memory(obj::S) where {S}
Base.unsafe_convert(Ptr{Cvoid}, [obj])
ref = Ref{S}(obj)
GC.@preserve ref Ptr{Cvoid}(Base.unsafe_convert(Ptr{S}, ref))
end

function _unsafe_reinterpret(::Type{T}, obj::S) where {T,S}
# Use unsafe_wrap to avoid copy from unsafe_load
# unsafe_load(Ptr{T}(Base.unsafe_convert(Ptr{Cvoid}, Ref{S}(obj))))
unsafe_wrap(Array, Ptr{T}(_pointer_to_c_memory(obj)), 1)[]
ref = Ref{S}(obj)
GC.@preserve ref unsafe_load(Ptr{T}(Base.unsafe_convert(Ptr{S}, ref)))
end

############################################
# Primitive type: quadrant_data
# represents the following p4est C-Unions:
# - p4est_quadrant_data
# - p6est_quadrant_data
# - p8est_quadrant_data
############################################
############################################
# Primitive type: quadrant_data
# represents the following p4est C-Unions:
# - p4est_quadrant_data
# - p6est_quadrant_data
# - p8est_quadrant_data
############################################
struct piggy1 which_tree::p4est_topidx_t; owner_rank::Cint; end
struct piggy2 which_tree::p4est_topidx_t; from_tree::p4est_topidx_t; end
struct piggy3 which_tree::p4est_topidx_t; local_num::p4est_locidx_t; end
Expand Down Expand Up @@ -108,7 +108,10 @@ iter_side_data_properties = (:full, :hanging)

# Biggest data size in union (24 bytes - 192 bits)
iter_side_data_2_union = Union{full, hanging{2}}
primitive type iter_side_data_2 8*sizeof(iter_side_data_2_union) end
struct iter_side_data_2
head::UInt64
tail::NTuple{24,UInt8}
end

function Base.getproperty(x::iter_side_data_2, name::Symbol)
if name == :full
Expand All @@ -125,15 +128,18 @@ Base.propertynames(x::iter_side_data_2) = (iter_side_data_properties..., fieldna
const p4est_iter_face_side_data = iter_side_data_2
const p8est_iter_edge_side_data = iter_side_data_2

############################################
# Primitive type: iter_side_data_4
# represents the following p4est C-Unions:
# - p8est_iter_face_side_data
############################################
############################################
# Primitive type: iter_side_data_4
# represents the following p4est C-Unions:
# - p8est_iter_face_side_data
############################################

# Biggest data size in union (32 bytes - 256 bits)
iter_side_data_4_union = Union{full, hanging{4}}
primitive type iter_side_data_4 8*sizeof(iter_side_data_4_union) end
struct iter_side_data_4
head::UInt64
tail::NTuple{48,UInt8}
end

function Base.getproperty(x::iter_side_data_4, name::Symbol)
if name == :full
Expand All @@ -148,4 +154,3 @@ end
Base.propertynames(x::iter_side_data_4) = (iter_side_data_properties..., fieldnames(DataType)...)

const p8est_iter_face_side_data = iter_side_data_4

7 changes: 7 additions & 0 deletions test/test_p8est_bindings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ using MPI
using P4est_wrapper
using Test

@test Base.datatype_alignment(P4est_wrapper.iter_side_data_4) == 8
@test Base.datatype_alignment(P4est_wrapper.iter_side_data_2) == 8
@test sizeof(P4est_wrapper.p8est_iter_face_side_t) == 64
@test fieldoffset(P4est_wrapper.p8est_iter_face_side_t, 4) == 8
@test sizeof(P4est_wrapper.p8est_iter_edge_side_t) == 48
@test fieldoffset(P4est_wrapper.p8est_iter_edge_side_t, 5) == 8

# Initialize MPI if not initialized yet
if !MPI.Initialized()
MPI.Init()
Expand Down
Loading