Synchronize pageable host uploads - #618
Merged
Merged
Conversation
Level Zero memory copies read their host source when the queued command executes, but Array uploads returned after submission and only preserved the source through that submission. A temporary source could therefore be collected and its storage reused before a delayed copy ran, silently corrupting device data. Synchronize the task-local queue inside the GC preserve region so pageable host memory remains valid until the upload completes. This deliberately makes Array-to-device copies synchronous, matching the existing device-to-Array behavior.
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/array.jl b/src/array.jl
index 4c80540..9a99f3e 100644
--- a/src/array.jl
+++ b/src/array.jl
@@ -445,12 +445,12 @@ Base.copyto!(dest::oneDenseArray{T}, src::oneDenseArray{T}) where {T} =
function Base.unsafe_copyto!(ctx::ZeContext, dev::ZeDevice,
dest::oneDenseArray{T}, doffs, src::Array{T}, soffs, n) where T
- GC.@preserve src dest begin
- unsafe_copyto!(ctx, dev, pointer(dest, doffs), pointer(src, soffs), n)
+ GC.@preserve src dest begin
+ unsafe_copyto!(ctx, dev, pointer(dest, doffs), pointer(src, soffs), n)
- # Keep pageable host memory alive until the queued copy completes.
- synchronize(global_queue(ctx, dev))
- end
+ # Keep pageable host memory alive until the queued copy completes.
+ synchronize(global_queue(ctx, dev))
+ end
if Base.isbitsunion(T)
# copy selector bytes
error("oneArray does not yet support isbits-union arrays") |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #618 +/- ##
==========================================
- Coverage 80.90% 79.02% -1.89%
==========================================
Files 50 50
Lines 3488 3490 +2
==========================================
- Hits 2822 2758 -64
- Misses 666 732 +66 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
ALCF pipeline is broken after a maintenance window. Filed a ticket. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Level Zero memory copies read their host source when the queued command executes, but Array uploads returned after submission and only preserved the source through that submission. A temporary source could therefore be collected and its storage reused before a delayed copy ran, silently corrupting device data.
Synchronize the task-local queue inside the GC preserve region so pageable host memory remains valid until the upload completes. This deliberately makes Array-to-device copies synchronous, matching the existing device-to-Array behavior.
I think this should solve the corruptions seen on AcceleratedKernels.jl.