Skip to content

[SYCL] Define interop type for images in Level-Zero and OpenCL backends #3606

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

Merged
merged 3 commits into from
Apr 28, 2021

Conversation

mikhail-nikolskiy
Copy link
Contributor

@mikhail-nikolskiy mikhail-nikolskiy commented Apr 23, 2021

Currently interop type defined for buffers only.
Tests: llvm-test-suite#252

add Level-Zero image interop
add OpenCL image interop
@romanovvlad
Copy link
Contributor

LGTM, @alexbatashev could you please take a look as well?

@alexbatashev
Copy link
Contributor

I think we agreed with @smaslov-intel we want to retire interop struct in favor of backend_traits.

smaslov-intel
smaslov-intel previously approved these changes Apr 26, 2021
@mikhail-nikolskiy
Copy link
Contributor Author

Tests instability fixed in test code by replacing '&' with '=' in interop_task lambda - copy accessor objects by value, not by reference. Otherwise accessor could be destroyed before interop_task starts.

@smaslov-intel
Copy link
Contributor

accessor could be destroyed before interop_task starts

The accessor should stay alive until it goes out of scope. I don't understand why this early destruction was possible.
If it is truly something that's going on then we should have it explained to the users in some form.

@alexbatashev
Copy link
Contributor

accessor could be destroyed before interop_task starts

The accessor should stay alive until it goes out of scope. I don't understand why this early destruction was possible.
If it is truly something that's going on then we should have it explained to the users in some form.

If I'm not mistaken, interop tasks run in a separate thread. Tagging @s-kanaev

@s-kanaev
Copy link
Contributor

If I'm not mistaken, interop tasks run in a separate thread.

There're two kinds of interop tasks:

  • the ones launched with cl::handler::interop_task()
  • host tasks with interop

The former are executed within the enqueueing thread.
The latter ones are executed in a distinct thread belonging to thread pool. See queue_impl::initHostTaskAndEventCallbackThreadPool(). Though the method is available in any queue, it's called only for default host queue.

@romanovvlad
Copy link
Contributor

@mikhail-nikolskiy Could you please apply clang-format suggestion?

@smaslov-intel
Copy link
Contributor

The former are executed within the enqueueing thread.

So how could accessors be destroyed earlier that the interop_task is completed?
intel/llvm-test-suite@df07c9e#diff-bf582222f4ea3305ae98fd3a169c8bdbb8ff7df2782592610154ced2d0edf6feR43

@s-kanaev
Copy link
Contributor

So how could accessors be destroyed earlier that the interop_task is completed?

We've got two lambdas here:

  • the one passed to queue::submit, lets call it command group handler lambda
  • the one passed to handler::interop_task, lets call it interop task lambda

Now, the accessor is created in command group handler lambda and referred to in interop task lambda. Though, upon call to handler::interop_task the interop lambda doesn't get to be executed. It's only stored. The enqueue process is started after command group handler lambda finishes, i.e. it returns and all its local objects got destroyed. Interop lambda is executed only whilst enqueue process.

@mikhail-nikolskiy
Copy link
Contributor Author

@mikhail-nikolskiy Could you please apply clang-format suggestion?
done

@smaslov-intel
Copy link
Contributor

Now, the accessor is created in command group handler lambda and referred to in interop task lambda. Though, upon call to handler::interop_task the interop lambda doesn't get to be executed. It's only stored. The enqueue process is started after command group handler lambda finishes, i.e. it returns and all its local objects got destroyed. Interop lambda is executed only whilst enqueue process.

Thanks for explaining this non-obvious behavior!
I think this may be a big source of user errors in future.
Is there a chance to give a compile-time error by building this knowledge into FE?

@bader bader merged commit a58cfef into intel:sycl Apr 28, 2021
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.

6 participants