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

[OPENCL] Add UR handles to OPENCL adapter #1176

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

Conversation

omarahmed1111
Copy link
Contributor

@omarahmed1111 omarahmed1111 commented Dec 11, 2023

Redesign Opencl adapter by adding UR handles and get rid of the casting of the UR handles to OPENCL handles.

Intel/llvm testing

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 12.43%. Comparing base (78ef1ca) to head (97dbfd0).
Report is 199 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    #1176      +/-   ##
==========================================
- Coverage   14.82%   12.43%   -2.40%     
==========================================
  Files         250      241       -9     
  Lines       36220    36242      +22     
  Branches     4094     4111      +17     
==========================================
- Hits         5369     4506     -863     
- Misses      30800    31732     +932     
+ Partials       51        4      -47     

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

@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 3 times, most recently from ceb8b8e to ff5ebc1 Compare December 14, 2023 10:45
@omarahmed1111 omarahmed1111 changed the title [OPENCL] Redesign FuncPtrExtCache by adding UR handles to OPENCL adapter [OPENCL] Add UR handles to OPENCL adapter Dec 14, 2023
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 10 times, most recently from f7b0de5 to 66d5282 Compare December 20, 2023 15:40
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 2 times, most recently from adb6b3d to 4777b93 Compare December 22, 2023 23:05
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 3 times, most recently from 11b092b to ff193b2 Compare January 12, 2024 13:56
@omarahmed1111 omarahmed1111 marked this pull request as ready for review January 12, 2024 14:34
@omarahmed1111 omarahmed1111 requested review from a team as code owners January 12, 2024 14:34
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 2 times, most recently from ab61e80 to 61ba805 Compare January 16, 2024 11:23
@omarahmed1111
Copy link
Contributor Author

omarahmed1111 commented Jan 23, 2024

I've not reviewed the whole PR yet. I think we need to run the CTS with the Address Sanitizer enabled to make sure we're not introducing memory leaks.

Used Address sanitizer to check for memory leaks, fixed some in the UR layer here. Some are generated from OpenCL sources so left that, others are generated from UR CTS tests that will be fixed in this PR

Copy link
Contributor

@aarongreig aarongreig left a comment

Choose a reason for hiding this comment

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

LGTM pending open discussions. This is an important change and I bet it wasn't fun to implement, thanks @omarahmed1111

source/adapters/opencl/platform.hpp Outdated Show resolved Hide resolved
source/adapters/opencl/program.cpp Outdated Show resolved Hide resolved
source/adapters/opencl/context.hpp Show resolved Hide resolved
source/adapters/opencl/program.cpp Outdated Show resolved Hide resolved
source/adapters/opencl/kernel.hpp Outdated Show resolved Hide resolved
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 4 times, most recently from bbf75b5 to 1c06a2b Compare January 26, 2024 16:40
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 2 times, most recently from ccbba77 to 9e6e28f Compare January 31, 2024 13:48
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 2 times, most recently from b95c58c to d9e1eee Compare February 7, 2024 10:32
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 2 times, most recently from 99291e1 to 68b70b9 Compare February 22, 2024 11:19
@omarahmed1111 omarahmed1111 force-pushed the Add-handles-to-opencl-adapter branch 3 times, most recently from 97dbfd0 to 820779f Compare March 26, 2024 13:22
@kbenzie kbenzie added the opencl OpenCL adapter specific issues label Apr 10, 2024
@github-actions github-actions bot added conformance Conformance test suite issues. command-buffer Command Buffer feature addition/changes/specification labels Oct 10, 2024
auto URContext =
std::make_unique<ur_context_handle_t_>(Ctx, DevCount, phDevices);
Context = URContext.release();
CL_RETURN_ON_FAILURE(clRetainContext(Ctx));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think for native handles we should mirror l0's behaviour, that's where isNativeHandleOwned was first implemented so we can assume it reflects the original intention. The UR handles don't retain the native handle, and isNativeHandleOwned decides whether UR will release the native handle when the UR handle is released.

So for example l0 context tracks whether it owns its native handle (the param gets passed from here to here) and only uses that information when it comes to releasing the context here

Copy link
Contributor

Choose a reason for hiding this comment

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

here's a draft for the new spec around native handles #2193

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That make sense, I changed it to mimic l0 behaviour.

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. opencl OpenCL adapter specific issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants