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] Remove deprecated hip APIs, simplify urContext #1830

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

JackAKirk
Copy link
Contributor

@JackAKirk JackAKirk commented Jul 8, 2024

hip amd does not have a native context type other than to support the cuContext type on Nvidia devices. hip plans to completely remove usage of this type anyway, with all corresponding APIs marked deprecated.

This PR future-proofs our hip implementation for when these deprecated APIs become unsupported. It also simplifies the urContext type.

This updates a context test to pass if the interface is unsupported, which cleans up the native_cpu match file that doesn't support certain context interfaces.

@JackAKirk JackAKirk requested review from a team as code owners July 8, 2024 15:45
@JackAKirk JackAKirk changed the title [hip] Remove deprecated hip apis, refactor urContext. [hip] Remove deprecated hip APIs, refactor urContext. Jul 8, 2024
@JackAKirk JackAKirk changed the title [hip] Remove deprecated hip APIs, refactor urContext. [hip] Remove deprecated hip APIs, simplify urContext. Jul 8, 2024
@JackAKirk
Copy link
Contributor Author

intel/llvm tested with these changes here: intel/llvm#14476

namespace {
/// Scoped Device is used across all UR HIP plugin implementation to activate
/// the native Device on the current thread. The ScopedDevice does not
/// reinstate the previous device as all operations in the hip adapter that
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this was copied from an older comment but we have HIP and hip in the same comment. I think HIP is best?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've used HIP consistently now.

@github-actions github-actions bot added hip HIP adapter specific issues command-buffer Command Buffer feature addition/changes/specification labels Jul 8, 2024
Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

command-buffer change LGTM

@JackAKirk JackAKirk added ready to merge Added to PR's which are ready to merge and removed ready to merge Added to PR's which are ready to merge labels Jul 9, 2024
@JackAKirk JackAKirk marked this pull request as draft July 10, 2024 11:57
@JackAKirk JackAKirk marked this pull request as ready for review July 11, 2024 10:27
@JackAKirk JackAKirk requested a review from a team as a code owner July 11, 2024 11:38
@github-actions github-actions bot added the conformance Conformance test suite issues. label Jul 11, 2024
@JackAKirk JackAKirk added ready to merge Added to PR's which are ready to merge and removed ready to merge Added to PR's which are ready to merge labels Jul 11, 2024
@JackAKirk JackAKirk changed the title [hip] Remove deprecated hip APIs, simplify urContext. [hip] Remove deprecated hip APIs, simplify urContext Jul 12, 2024
@JackAKirk JackAKirk added the ready to merge Added to PR's which are ready to merge label Jul 12, 2024
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 with a few minor questions.

source/adapters/hip/context.hpp Outdated Show resolved Hide resolved
std::vector<ur_device_handle_t> Devices;

std::atomic_uint32_t RefCount;

ur_context_handle_t_(const ur_device_handle_t *Devs, uint32_t NumDevices)
: Devices{Devs, Devs + NumDevices}, RefCount{1} {
for (auto &Dev : Devices) {
urDeviceRetain(Dev);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why no longer retaining ur devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added it back.

if (!hDevice) {
throw UR_RESULT_ERROR_INVALID_DEVICE;
}
UR_CHECK_ERROR(hipSetDevice(hDevice->getIndex()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

Mostly these APIs were completely redundant already. HIP amd doesn't have have a context concept.

Signed-off-by: JackAKirk <[email protected]>
hip -> HIP in comment.

Signed-off-by: JackAKirk <[email protected]>
The test should have been checking for success or unsupported, since most backends don't support context interop.

Signed-off-by: JackAKirk <[email protected]>
@omarahmed1111
Copy link
Contributor

@JackAKirk Please make sure intel/llvm#14476 is updated and passing CI, so we could merge this. Thanks!

@kbenzie kbenzie removed the ready to merge Added to PR's which are ready to merge label Sep 17, 2024
@kbenzie
Copy link
Contributor

kbenzie commented Sep 17, 2024

I've removed ready to merge since the intel/llvm PR isn't passing testing and is still awaiting approvals. Once these are in place, add the ready to merge label again.

@JackAKirk
Copy link
Contributor Author

This updates a context test to pass if the interface is unsupported, which cleans up the native_cpu match file that doesn't support certain context interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-buffer Command Buffer feature addition/changes/specification conformance Conformance test suite issues. hip HIP adapter specific issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants