Skip to content

Commit f27d4e1

Browse files
committed
Merge branch 'master' into dl/invdisk
2 parents 0af515c + 983a851 commit f27d4e1

2 files changed

Lines changed: 49 additions & 20 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
- pull_request
55
jobs:
66
test:
7-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
7+
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
fail-fast: false
@@ -14,19 +14,12 @@ jobs:
1414
- '1'
1515
os:
1616
- ubuntu-latest
17-
# - macOS-latest
18-
arch:
19-
- x86
20-
- x64
21-
exclude:
22-
- os: macOS-latest
23-
arch: x86
17+
- macOS-latest
2418
steps:
25-
- uses: actions/checkout@v4
26-
- uses: julia-actions/setup-julia@v2
19+
- uses: actions/checkout@v6
20+
- uses: julia-actions/setup-julia@v3
2721
with:
2822
version: ${{ matrix.version }}
29-
arch: ${{ matrix.arch }}
3023
show-versioninfo: true
3124
- uses: actions/cache@v3
3225
env:
@@ -38,10 +31,10 @@ jobs:
3831
${{ runner.os }}-test-${{ env.cache-name }}-
3932
${{ runner.os }}-test-
4033
${{ runner.os }}-
41-
- uses: julia-actions/julia-buildpkg@latest
42-
- uses: julia-actions/julia-runtest@latest
34+
- uses: julia-actions/julia-buildpkg@v1
35+
- uses: julia-actions/julia-runtest@v1
4336
- uses: julia-actions/julia-processcoverage@v1
44-
- uses: codecov/codecov-action@v4
37+
- uses: codecov/codecov-action@v6
4538
with:
4639
token: ${{ secrets.CODECOV_TOKEN }}
4740
file: lcov.info

‎src/libfasttransforms.jl‎

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ function renew!(x::AbstractArray{BigFloat})
4949
return x
5050
end
5151

52+
# Obtain a raw C pointer to the mpfr_t struct underlying a BigFloat.
53+
# In Julia < 1.12, BigFloat was a mutable struct whose fields matched mpfr_t directly,
54+
# so pointer_from_objref gives us the mpfr_t*.
55+
# In Julia >= 1.12, BigFloat is an immutable struct wrapping Memory{Limb}, and the
56+
# mpfr_t struct is stored at the start of that Memory.
57+
@static if VERSION >= v"1.12"
58+
_mpfr_ptr(b::BigFloat) = Ptr{mpfr_t}(pointer(getfield(b, :d)))
59+
else
60+
_mpfr_ptr(b::BigFloat) = Ptr{mpfr_t}(pointer_from_objref(b))
61+
end
62+
63+
5264
function horner!(f::Vector{Float64}, c::StridedVector{Float64}, x::Vector{Float64})
5365
@assert length(x) == length(f)
5466
ccall((:ft_horner, libfasttransforms), Cvoid, (Cint, Ptr{Float64}, Cint, Cint, Ptr{Float64}, Ptr{Float64}), length(c), c, stride(c, 1), length(x), x, f)
@@ -983,19 +995,31 @@ for (fJ, fC) in ((:lmul!, :ft_mpfr_trmv_ptr),
983995
function $fJ(p::FTPlan{BigFloat, 1}, x::StridedVector{BigFloat})
984996
checksize(p, x)
985997
checkstride(p, x)
986-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Int32), 'N', p.n, p, p.n, renew!(x), Base.MPFR.ROUNDING_MODE[])
998+
renew!(x)
999+
GC.@preserve x begin
1000+
ptrs = map(_mpfr_ptr, x)
1001+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Int32), 'N', p.n, p, p.n, ptrs, Base.MPFR.ROUNDING_MODE[])
1002+
end
9871003
return x
9881004
end
9891005
function $fJ(p::AdjointFTPlan{BigFloat, FTPlan{BigFloat, 1, K}}, x::StridedVector{BigFloat}) where K
9901006
checksize(p, x)
9911007
checkstride(p, x)
992-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Int32), 'T', p.parent.n, p, p.parent.n, renew!(x), Base.MPFR.ROUNDING_MODE[])
1008+
renew!(x)
1009+
GC.@preserve x begin
1010+
ptrs = map(_mpfr_ptr, x)
1011+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Int32), 'T', p.parent.n, p, p.parent.n, ptrs, Base.MPFR.ROUNDING_MODE[])
1012+
end
9931013
return x
9941014
end
9951015
function $fJ(p::TransposeFTPlan{BigFloat, FTPlan{BigFloat, 1, K}}, x::StridedVector{BigFloat}) where K
9961016
checksize(p, x)
9971017
checkstride(p, x)
998-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Int32), 'T', p.parent.n, p, p.parent.n, renew!(x), Base.MPFR.ROUNDING_MODE[])
1018+
renew!(x)
1019+
GC.@preserve x begin
1020+
ptrs = map(_mpfr_ptr, x)
1021+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Int32), 'T', p.parent.n, p, p.parent.n, ptrs, Base.MPFR.ROUNDING_MODE[])
1022+
end
9991023
return x
10001024
end
10011025
end
@@ -1083,19 +1107,31 @@ for (fJ, fC) in ((:lmul!, :ft_mpfr_trmm_ptr),
10831107
function $fJ(p::FTPlan{BigFloat, 1}, x::StridedMatrix{BigFloat})
10841108
checksize(p, x)
10851109
checkstride(p, x)
1086-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Cint, Cint, Int32), 'N', p.n, p, p.n, renew!(x), stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1110+
renew!(x)
1111+
GC.@preserve x begin
1112+
ptrs = map(_mpfr_ptr, x)
1113+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Cint, Cint, Int32), 'N', p.n, p, p.n, ptrs, stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1114+
end
10871115
return x
10881116
end
10891117
function $fJ(p::AdjointFTPlan{BigFloat, FTPlan{BigFloat, 1, K}}, x::StridedMatrix{BigFloat}) where K
10901118
checksize(p, x)
10911119
checkstride(p, x)
1092-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Cint, Cint, Int32), 'T', p.parent.n, p, p.parent.n, renew!(x), stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1120+
renew!(x)
1121+
GC.@preserve x begin
1122+
ptrs = map(_mpfr_ptr, x)
1123+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Cint, Cint, Int32), 'T', p.parent.n, p, p.parent.n, ptrs, stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1124+
end
10931125
return x
10941126
end
10951127
function $fJ(p::TransposeFTPlan{BigFloat, FTPlan{BigFloat, 1, K}}, x::StridedMatrix{BigFloat}) where K
10961128
checksize(p, x)
10971129
checkstride(p, x)
1098-
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{BigFloat}, Cint, Cint, Int32), 'T', p.parent.n, p, p.parent.n, renew!(x), stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1130+
renew!(x)
1131+
GC.@preserve x begin
1132+
ptrs = map(_mpfr_ptr, x)
1133+
ccall(($(string(fC)), libfasttransforms), Cvoid, (Cint, Cint, Ptr{mpfr_t}, Cint, Ptr{Ptr{mpfr_t}}, Cint, Cint, Int32), 'T', p.parent.n, p, p.parent.n, ptrs, stride(x, 2), size(x, 2), Base.MPFR.ROUNDING_MODE[])
1134+
end
10991135
return x
11001136
end
11011137
end

0 commit comments

Comments
 (0)