Skip to content

Add CUDA.return_type - #1339

Merged
maleadt merged 4 commits into
JuliaGPU:masterfrom
tkf:return_type
Jan 26, 2022
Merged

maleadt merged 4 commits into
JuliaGPU:masterfrom
tkf:return_type

Conversation

@tkf

@tkf tkf commented Jan 26, 2022 •

Copy link
Copy Markdown
Contributor

This PR adds CUDA.return_type which is like Core.Compiler.return_type but for kernel code. I think something like this is required for pre-allocating buffers for user-defined functions using kernel-only API. For example, code using CUDA.arrayref on a device array cannot be inferred without something like this, IIUC.

I'd like to use an API like this here https://github.com/JuliaFolds/FoldsCUDA.jl/blob/e4fd83e66222350647e659c2be676a7c8136adf3/src/kernels.jl#L107 to allocate the intermediate accumulation result

Comment on lines +146 to +147
interp = GPUCompiler.get_interpreter(job)
return Core.Compiler.return_type(interp, job.source.f, job.source.tt)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to have GPUCompiler.return_type like other reflection tools do?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting a job argument then? It wouldn't do much except for getting an interpreter and forwarding it to Core.Compiler.return_type, so it doesn't seem worth the hassle.

Comment thread src/compiler/reflection.jl Outdated

@maleadt maleadt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@maleadt
maleadt merged commit baa8d78 into JuliaGPU:master Jan 26, 2022
@tkf
tkf deleted the return_type branch January 26, 2022 09:09
simonbyrne pushed a commit to simonbyrne/CUDA.jl that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants