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

Fix KernelAbstractions for Unified Memory #316

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Fix KernelAbstractions for Unified Memory #316

merged 2 commits into from
Mar 13, 2024

Conversation

tgymnich
Copy link
Member

@tgymnich tgymnich commented Mar 12, 2024

Follow up for #314

@tgymnich tgymnich mentioned this pull request Mar 12, 2024
@tgymnich tgymnich marked this pull request as ready for review March 12, 2024 17:15
@@ -35,20 +35,20 @@ Adapt.adapt_storage(::KA.CPU, a::MtlArray) = convert(Array, a)

function KA.copyto!(::MetalBackend, A::MtlArray{T}, B::MtlArray{T}) where T
if device(dest) == device(src)
GC.@preserve A B unsafe_copyto!(device(A), pointer(A), pointer(B), length(A); async=true)
GC.@preserve A B copyto!(A, B)
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this just hide the issue? It's a good change, but only fixes the issue because copyto! currently always synchronizes. Ideally it shouldn't for certain copies, like CUDA.jl doesn't for CuArray->CuArray copies: https://github.com/JuliaGPU/CUDA.jl/blob/bb49887198f258ffcb186d81df4a787453428b38/src/array.jl#L622-L633

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. This should then probably all be handled by MTLBlitCommandEncoder

@maleadt maleadt merged commit bb33fa5 into main Mar 13, 2024
1 check passed
@maleadt maleadt deleted the ka-unified-mem branch March 13, 2024 11:49
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