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

Make copies from host to device blocking #243

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Oct 1, 2024

Otherwise the following simple example fails:

# allocate CPU arrays
A = Int32[1]
R = zeros(Int32, 1)

# allocate GPU arrays
dA = CLArray(A)
dR = CLArray(R)

R .+= 1
# XXX: the asynchronous `CLArray(R)` only executes here,
#      resulting in dR containing the result _after_ the increment
dR .+= 1

# dR != R
# dR: [2]
# R:  [1]

It's very surprising to me that we haven't encountered this issue with our other back-ends. I assume that CUDA.jl's handling of unpinned memory (which it first copies synchronously into a pinned staging buffer) masks a lot of issues here.

Still, we'll probably have to make this change in other back-ends as well, because the memory could just as well have been fried before the copy finishes.

@maleadt maleadt force-pushed the tb/blocking_memcpy branch from 9950447 to 3a19188 Compare October 1, 2024 14:04
@maleadt maleadt changed the title Tb/blocking memcpy Make copies from host to device blocking Oct 1, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.03%. Comparing base (8aca9d7) to head (3a19188).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #243   +/-   ##
=======================================
  Coverage   64.03%   64.03%           
=======================================
  Files           9        9           
  Lines         456      456           
=======================================
  Hits          292      292           
  Misses        164      164           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maleadt maleadt merged commit 3621255 into master Oct 1, 2024
5 checks passed
@maleadt maleadt deleted the tb/blocking_memcpy branch October 1, 2024 14:15
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.

1 participant