Skip to content

Commit 57ca963

Browse files
authored
Fixes for Julia 1.11 (#2240)
1 parent 530f1c6 commit 57ca963

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

lib/cudadrv/module/linker.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,30 @@ end
6666
Add PTX code to a pending link operation.
6767
"""
6868
function add_data!(link::CuLink, name::String, code::String)
69-
data = unsafe_wrap(Vector{UInt8}, code)
70-
71-
# there shouldn't be any embedded NULLs
72-
checked_data = Base.unsafe_convert(Cstring, data)
73-
74-
res = unsafe_cuLinkAddData_v2(link, JIT_INPUT_PTX, pointer(checked_data), length(data),
75-
name, 0, C_NULL, C_NULL)
76-
if res == ERROR_NO_BINARY_FOR_GPU ||
77-
res == ERROR_INVALID_IMAGE ||
78-
res == ERROR_INVALID_PTX
79-
throw(CuError(res, unsafe_string(pointer(link.options[JIT_ERROR_LOG_BUFFER]))))
80-
elseif res != SUCCESS
81-
throw_api_error(res)
69+
GC.@preserve code begin
70+
# cuLinkAddData takes a Ptr{Cvoid} instead of a Cstring, because it accepts both
71+
# source and binary, so do the conversion (ensuring no embedded NULLs) ourselves
72+
data = Base.unsafe_convert(Cstring, code)
73+
74+
res = unsafe_cuLinkAddData_v2(link, JIT_INPUT_PTX, pointer(data), length(code),
75+
name, 0, C_NULL, C_NULL)
76+
if res == ERROR_NO_BINARY_FOR_GPU ||
77+
res == ERROR_INVALID_IMAGE ||
78+
res == ERROR_INVALID_PTX
79+
throw(CuError(res, unsafe_string(pointer(link.options[JIT_ERROR_LOG_BUFFER]))))
80+
elseif res != SUCCESS
81+
throw_api_error(res)
82+
end
8283
end
8384
end
8485

8586
"""
86-
add_data!(link::CuLink, name::String, data::Vector{UInt8}, type::CUjitInputType)
87+
add_data!(link::CuLink, name::String, data::Vector{UInt8})
8788
8889
Add object code to a pending link operation.
8990
"""
9091
function add_data!(link::CuLink, name::String, data::Vector{UInt8})
91-
res = unsafe_cuLinkAddData_v2(link, JIT_INPUT_OBJECT, pointer(data), length(data),
92+
res = unsafe_cuLinkAddData_v2(link, JIT_INPUT_OBJECT, data, length(data),
9293
name, 0, C_NULL, C_NULL)
9394
if res == ERROR_NO_BINARY_FOR_GPU ||
9495
res == ERROR_INVALID_IMAGE ||
@@ -97,8 +98,6 @@ function add_data!(link::CuLink, name::String, data::Vector{UInt8})
9798
elseif res != SUCCESS
9899
throw_api_error(res)
99100
end
100-
101-
return
102101
end
103102

104103
"""

src/array.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,14 @@ end
512512

513513
## memory copying
514514

515+
if VERSION >= v"1.11.0-DEV.753"
516+
function typetagdata(a::Array, i=1)
517+
ptr_or_offset = Int(a.ref.ptr_or_offset)
518+
@ccall(jl_genericmemory_typetagdata(a.ref.mem::Any)::Ptr{UInt8}) + ptr_or_offset + i - 1
519+
end
520+
else
515521
typetagdata(a::Array, i=1) = ccall(:jl_array_typetagdata, Ptr{UInt8}, (Any,), a) + i - 1
522+
end
516523
function typetagdata(a::CuArray, i=1; type=Mem.Device)
517524
PT = if type == Mem.Device
518525
CuPtr{UInt8}

src/compiler/execution.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ No keyword arguments are supported.
419419
DeviceKernel{F,tt}(f, fun, kernel_state())
420420
end
421421

422-
(kernel::DeviceKernel)(args...; kwargs...) = call(kernel, args...; kwargs...)
422+
@inline (kernel::DeviceKernel)(args::Vararg{Any,N}; kwargs...) where {N} =
423+
call(kernel, args...; kwargs...)
423424

424425
# re-use the parent kernel's seed to avoid need for the RNG
425426
make_seed(::DeviceKernel) = kernel_state().random_seed

src/device/intrinsics/output.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const cuprint_specifiers = Dict(
168168
fmt *= string(T.parameters[1])
169169
else
170170
@warn("@cuprint does not support values of type $T")
171-
fmt *= "$(string(T.parameters[1]))(...)"
171+
fmt *= "$(T)(...)"
172172
end
173173
end
174174

src/indexing.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ using Base.Cartesian
1212
# TODO: it should still be possible to use the same technique;
1313
# Base.LogicalIndex basically contains the same as our `findall` here does.
1414
Base.to_index(::CuArray, I::AbstractArray{Bool}) = findall(I)
15-
## same for the trailing Array{Bool} optimization (see `_maybe_linear_logical_index` in Base)
16-
Base.to_indices(A::CuArray, inds,
17-
I::Tuple{Union{Array{Bool,N}, BitArray{N}}}) where {N} =
18-
(Base.to_index(A, I[1]),)
15+
if VERSION >= v"1.11.0-DEV.1157"
16+
Base.to_indices(A::CuArray, I::Tuple{AbstractArray{Bool}}) = (Base.to_index(A, I[1]),)
17+
else
18+
Base.to_indices(A::CuArray, inds,
19+
I::Tuple{Union{Array{Bool,N}, BitArray{N}}}) where {N} =
20+
(Base.to_index(A, I[1]),)
21+
end
1922

2023

2124
## find*

0 commit comments

Comments
 (0)