-
Notifications
You must be signed in to change notification settings - Fork 753
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
Use new UR handles for opencl instead of casting mechanism #12172
base: sycl
Are you sure you want to change the base?
Use new UR handles for opencl instead of casting mechanism #12172
Conversation
3acda17
to
f3f6360
Compare
49e2da4
to
69c4f49
Compare
69c4f49
to
e95d890
Compare
bfe155f
to
643dcf3
Compare
643dcf3
to
503faa9
Compare
503faa9
to
9eed560
Compare
9eed560
to
de060f6
Compare
de060f6
to
4ea421e
Compare
4ea421e
to
ce846a0
Compare
// Enqueuing an interop kernel while avoid calls to piKernelSetArg from | ||
// different threads on the same kernel. | ||
{ | ||
constexpr std::size_t NArgs = 16; | ||
constexpr std::size_t ThreadCount = 4; | ||
constexpr std::size_t LaunchCount = 8; | ||
auto TestLambda = [&](int ThreadId) { | ||
Queue | ||
.submit([&](sycl::handler &CGH) { | ||
for (std::size_t I = 0; I < NArgs; ++I) | ||
CGH.set_arg(I, &ThreadId); | ||
}) | ||
.wait(); | ||
}; | ||
|
||
std::vector<std::thread> threadPool; | ||
threadPool.reserve(ThreadCount); | ||
for (size_t tid = 0; tid < ThreadCount; ++tid) { | ||
threadPool.push_back(std::thread(TestLambda, tid)); | ||
} | ||
|
||
for (auto ¤tThread : threadPool) { | ||
currentThread.join(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing a deprecated feature, do we really need to add to the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just combining and moving the 2 unittests SetArgForLocalAccessor
and InteropKernelEnqueue
to here. So, it is just keeping an existing test until this is completely deprecated and removed.
std::cerr << "Release native context." << std::endl; | ||
clReleaseContext(native_context); | ||
|
||
std::cerr << "Make kernel bundle." << std::endl; | ||
auto bundle = make_kernel_bundle<backend::opencl, bundle_state::executable>( | ||
p, q.get_context()); | ||
std::cerr << "Release native program." << std::endl; | ||
// cl_program must have been retained by the above call. | ||
clReleaseProgram(p); | ||
|
||
std::cerr << "Get native program." << std::endl; | ||
std::vector<cl_program> device_image = | ||
get_native<backend::opencl, bundle_state::executable>(bundle); | ||
assert(device_image.size() == 1); | ||
std::cerr << "Create native kernel." << std::endl; | ||
cl_kernel k = clCreateKernel(device_image.front(), "do_nothing", nullptr); | ||
// get_native must have retained cl_program as well. | ||
clReleaseProgram(device_image.front()); | ||
|
||
std::cerr << "Make kernel." << std::endl; | ||
make_kernel<backend::opencl>(k, q.get_context()); | ||
std::cerr << "Release native kernel." << std::endl; | ||
clReleaseKernel(k); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not at all sure about removing these release calls. What's the justification for doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context is not owned by the program but was created by sycl-rt initially and the test only retrieved it with get_native
so, it shouldn't releasing it as sycl-rt is responsible for that release. the program and kernel was created by the test so I have added the release calls for them back.
5562844
to
46592fe
Compare
46592fe
to
5c296e3
Compare
5b170a6
to
21e7aa7
Compare
21e7aa7
to
41e1826
Compare
41e1826
to
51cef66
Compare
This PR changes sycl-rt for opencl interop functionality to use the new UR handles layer for opencl, instead of relying on casting directly handles directly. So, it removes the 1:1 relation between UR/sycl-rt and opencl.
The changes in this PR involves:
retains
in sycl-rt as this will retain UR objects which are already owned by sycl-rt to make it and release it. Before this PR, this was needed as sycl-rt was being passed the opencl handle itself so it could have released it while still being used in the sycl application so we needed to retain it but this PR removes the 1:1 mapping between UR handles and OpenCL handles so this should no longer be needed.SetArgForLocalAccessor.cpp
andInteropKernelEnqueue.cpp
unittests to beDeprecatedFeatures/set_arg_interop.cpp
e2e-test. For more context refer to this commentUR PR