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

[HIP] Explicitly specify copy direction for USM 2D async memory copies #1194

Merged
merged 3 commits into from
Feb 2, 2024

Conversation

GeorgeWeb
Copy link
Contributor

@GeorgeWeb GeorgeWeb commented Dec 14, 2023

There is an issue with hipMemcpy2D* when hipMemcpyDefault is used, which makes the HIP runtime not correctly derive the copy kind (direction) for the copies introduced since ROCm 5.6.0. See: ROCm/clr#40.

This PR aims to provide a work-around in the meantime even though having to introduce the overhead of hipPointerGetAttributes in the memcpy2D. It patches it to work for the all possible copy kind directions (host / device / os-allocated host pageable memory) explicitly. Ideally, ROCm will fix the API when using just hipMemcpyDefault going forward.

Testing: intel/llvm/pull/12200

@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9f88cf8) 15.73% compared to head (64b99d2) 15.73%.
Report is 7 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1194   +/-   ##
=======================================
  Coverage   15.73%   15.73%           
=======================================
  Files         223      223           
  Lines       31477    31478    +1     
  Branches     3558     3558           
=======================================
+ Hits         4953     4954    +1     
  Misses      26473    26473           
  Partials       51       51           

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

@hdelan
Copy link
Contributor

hdelan commented Dec 15, 2023

An #ifdef for ROCm version might be a good idea, as well as a comment that the hipMemcpyDefault is broken in HIP. (Maybe even link this ROCm/clr#40 in the comment)

@GeorgeWeb GeorgeWeb changed the title [draft][HIP] Explicitly specify copy direction for USM 2D async memcpy [HIP] Explicitly specify copy direction for USM 2D async memory copies Dec 15, 2023
@GeorgeWeb GeorgeWeb marked this pull request as ready for review December 15, 2023 12:38
@GeorgeWeb GeorgeWeb requested a review from a team as a code owner December 15, 2023 12:38
@GeorgeWeb
Copy link
Contributor Author

GeorgeWeb commented Dec 15, 2023

An #ifdef for ROCm version might be a good idea, as well as a comment that the hipMemcpyDefault is broken in HIP. (Maybe even link this ROCm/clr#40 in the comment)

Updated this now, changes applicable to using ROCm HIP version 5.6.0 and above only.

@GeorgeWeb GeorgeWeb force-pushed the georgi/usm-copy2d-direction branch 2 times, most recently from 4c5c755 to f01cf61 Compare December 15, 2023 13:00
Copy link
Contributor

@mmoadeli mmoadeli left a comment

Choose a reason for hiding this comment

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

LGTM.
A minor issue might be using empty curly braces on declrations, which seems inconsistent with the rest of the file.

@GeorgeWeb GeorgeWeb closed this Dec 16, 2023
@hdelan
Copy link
Contributor

hdelan commented Dec 18, 2023

Why did you close this @GeorgeWeb ? We could still use this fix

@GeorgeWeb GeorgeWeb reopened this Dec 18, 2023
@GeorgeWeb
Copy link
Contributor Author

Why did you close this @GeorgeWeb ? We could still use this fix

Didn't mean to actually. Re-opening now.

@GeorgeWeb
Copy link
Contributor Author

Pinging @npmiller @hdelan @mmoadeli for final thoughts. Thanks!

Based on discussion in the original issue raised in ROCm/clr it seems this workaround will be needed as the fix is not going to be cherry-picked into older releases. Also it is unclear which of the next releases will have the fix, when that is clear this patch can be ifdef'd for the range of releases starting from ROCm 5.6.0 until ROCm 6.x that has their fix.

Copy link
Contributor

@hdelan hdelan left a comment

Choose a reason for hiding this comment

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

LGTM. I might just add a comment to say TODO: Add HIP max version when bug has been fixed just at the ifdef

@GeorgeWeb
Copy link
Contributor Author

TODO: Add HIP max version when bug has been fixed

Yeah makes sense. Easy to lose track of these.

@npmiller
Copy link
Contributor

Pinging for final thoughts. Thanks!

Based on discussion in the original issue raised in ROCm/clr it seems this workaround will be needed as the fix is not going to be cherry-picked into older releases. Also it is unclear which of the next releases will have the fix, when that is clear this patch can be ifdef'd for the range of releases starting from ROCm 5.6.0 until ROCm 6.x that has their fix.

That reasoning makes sense to me

@GeorgeWeb GeorgeWeb added the ready to merge Added to PR's which are ready to merge label Jan 24, 2024
@kbenzie kbenzie merged commit 76a2a9d into oneapi-src:main Feb 2, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Added to PR's which are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants