diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..31b3b03 --- /dev/null +++ b/.github/dependabot.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/ci-jll.yml b/.github/workflows/ci-jll.yml index 489f408..8a4ac5a 100644 --- a/.github/workflows/ci-jll.yml +++ b/.github/workflows/ci-jll.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1db9161..34fce59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/src/common_fixes.jl b/src/common_fixes.jl index 03b5cdb..1161d10 100644 --- a/src/common_fixes.jl +++ b/src/common_fixes.jl @@ -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 @@ -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 @@ -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 @@ -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 - diff --git a/test/test_p8est_bindings.jl b/test/test_p8est_bindings.jl index 31aae6e..b39011a 100644 --- a/test/test_p8est_bindings.jl +++ b/test/test_p8est_bindings.jl @@ -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()