Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for printing types. #2003

Merged
merged 1 commit into from
Jul 18, 2023
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
5 changes: 4 additions & 1 deletion src/device/intrinsics/output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ const cuprint_specifiers = Dict(
fmt *= ")"
elseif T <: String
@error("@cuprint does not support non-literal strings")
elseif T <: Type
fmt *= string(T.parameters[1])
else
@error("@cuprint does not support values of type $T")
@warn("@cuprint does not support values of type $T")
fmt *= "$(string(T.parameters[1]))(...)"
end
end

Expand Down
3 changes: 3 additions & 0 deletions test/core/device/intrinsics/output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ end
_, out = @grab_output @on_device @cuprint(4, 2)
@test out == "42"

_, out = @grab_output @on_device @cuprint(Any)
@test out == "Any"

# bug: @cuprintln failed to invokce @cuprint with endline in the case of interpolation
_, out = @grab_output @on_device @cuprintln("foobar $(42)")
@test out == "foobar 42$endline"
Expand Down