Skip to content

[SYCL][ESIMD][EMU] single_task support, v.2 #5671

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 1 commit into from
Mar 9, 2022

Conversation

lsatanov
Copy link
Contributor

  • ESIMD EMU: single_task() support.
  • ESIMD plugin: misc clarifying refactoring.

@lsatanov lsatanov requested a review from a team as a code owner February 25, 2022 10:26
@lsatanov lsatanov requested a review from againull February 25, 2022 10:26
@lsatanov lsatanov marked this pull request as draft February 25, 2022 10:27
@lsatanov lsatanov force-pushed the single-task-test-v2 branch 2 times, most recently from 7023689 to b9acc83 Compare February 25, 2022 11:19
@lsatanov lsatanov changed the title Draft v2, ESIMD EMU, single_task [SYCL][ESIMD][EMU] single_task support. Feb 25, 2022
@lsatanov lsatanov changed the title [SYCL][ESIMD][EMU] single_task support. [SYCL][ESIMD][EMU] single_task support, v.2 Feb 25, 2022
@@ -16,6 +16,7 @@

#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/detail/accessor_impl.hpp>
#include <CL/sycl/detail/cg_types.hpp> // for HostKernelBase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remnant from variant 1. Will eliminate after testing completes

@@ -142,38 +143,21 @@ static char ESimdEmuVersionString[32];

using IDBuilder = sycl::detail::Builder;

using HostKernelBase = cl::sycl::detail::HostKernelBase;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remnant from variant 1. Will eliminate after testing completes

@lsatanov lsatanov force-pushed the single-task-test-v2 branch 5 times, most recently from d2fbf16 to b206c79 Compare February 28, 2022 11:28
@lsatanov lsatanov marked this pull request as ready for review February 28, 2022 14:06
Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

@romanovvlad, @smaslov-intel - please take a look as well.

*/
// For 'void' and 'sycl::group<Dims>' kernel argument
// For 'sycl::group<Dims>' kernel argument
Copy link
Contributor

Choose a reason for hiding this comment

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

please use single comment style - '//'

@@ -246,6 +246,7 @@ template <class KernelType, class KernelArgType, int Dims>
class HostKernel : public HostKernelBase {
using IDBuilder = sycl::detail::Builder;
KernelType MKernel;

Copy link
Contributor

Choose a reason for hiding this comment

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

here and in other places - please avoid unrelated changes like adding empty lines


/* 'wrapper'-based approach using 'NormalizedKernelType' struct is not used
* for 'void(sycl::group<Dims>)' since 'void(sycl::group<Dims>)' is not
* supported in ESIMD.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is sycl::group<Dims> kernel supported at all (non-ESIMD case)? If not, then RT error would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My current understanding is the following: it's a "won't happen" case for ESIMD, hence no error.
Shall review this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming something won't happen and just ignoring the possibility is not safe. Please add error reporting.

Copy link
Contributor Author

@lsatanov lsatanov Mar 10, 2022

Choose a reason for hiding this comment

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

That's true. This code was introduced previously and results in runtime failure in case of using esimd emu backend without marking kernel as ESIMD kernel. If kernel is marked as ESIMD kernel - the compiler crashes without a human-friendly error report, which is also to be fixed.

All of it is to be addressed in the following changes.

template <int NDims> struct LambdaWrapper {
// kernel execution. Function instances of 'KernelWrapper' un-wrap
// this struct instance and invoke lambda function ('Func')
template <int NDims> struct KernelWrapperData {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how KernelWrapper is better than InvokeLambda. If Lambda does not cover all kernel cases then InvokeKernel or KernelInvoker?
Then KernelWrapperData -> KernelInvocationContext.

If this all is only supposed to be used on a host device (and/or esimd emulator), then I'd add 'Host' prefix as well.

Copy link
Contributor Author

@lsatanov lsatanov Mar 1, 2022

Choose a reason for hiding this comment

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

Warning: naming discussion.
Ok, the point was to make more sense (and less code). Yes, kernel is not always lambda.

There are many ways to do it. I consider KernelWrapper and KernelWrapperData clear enough and find adding "Host" prefix for things used inside esimd_emulator only an overkill and not bringing more sense.

If inevitable, the naming can be changed to the required liking.
e.g.,

InvokeKernel
KernelInvocationContext

would be totally clear.

Copy link
Contributor

@kbobrovs kbobrovs Mar 8, 2022

Choose a reason for hiding this comment

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

Classes should not be named with verbs, but adhjectives. KernelCaller, KernelInvoker

Warning: naming discussion.

Not sure I understand the warning. You started changing names, so I commented.

Copy link
Contributor Author

@lsatanov lsatanov Mar 9, 2022

Choose a reason for hiding this comment

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

Konstantin, I understand your point, but InvokeKernel is a function (template), not a class.

P.S. regarding classes, how they should be named (verbs/adjectives/nouns) is debatable taking into account that they can be callable in C++ (as we all know). In other languages, e.g. JavaScript, everything is an object (including functions). Should we name everything in JavaScript not using verbs? I doubt that.

@lsatanov lsatanov force-pushed the single-task-test-v2 branch 3 times, most recently from edd7398 to a538630 Compare March 1, 2022 16:01
romanovvlad
romanovvlad previously approved these changes Mar 1, 2022
Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

LGTM

@lsatanov lsatanov dismissed stale reviews from dongkyunahn-intel and romanovvlad via 970344d March 2, 2022 10:38
@lsatanov lsatanov force-pushed the single-task-test-v2 branch from a538630 to 970344d Compare March 2, 2022 10:38
[SYCL][ESIMD][EMU] misc clarifying plugin refactoring.
@lsatanov lsatanov force-pushed the single-task-test-v2 branch from 970344d to b7e60c1 Compare March 3, 2022 13:42
@lsatanov
Copy link
Contributor Author

lsatanov commented Mar 7, 2022

@romanovvlad, @kbobrovs hi. Merging?

@romanovvlad romanovvlad merged commit 2331160 into intel:sycl Mar 9, 2022
@bader
Copy link
Contributor

bader commented Mar 10, 2022

@lsatanov, this patch break the build due to

/home/runner/work/llvm/llvm/src/sycl/include/CL/sycl/handler.hpp:671:44: error: unused parameter 'Arg' [-Werror,-Wunused-parameter]
      void operator()(const nd_item<Dims> &Arg) {
                                           ^
1 error generated.

Could you fix this issue, please?
See full log here: https://github.com/intel/llvm/runs/5493988722?check_suite_focus=true

@lsatanov
Copy link
Contributor Author

lsatanov commented Mar 10, 2022

@lsatanov, this patch break the build due to

/home/runner/work/llvm/llvm/src/sycl/include/CL/sycl/handler.hpp:671:44: error: unused parameter 'Arg' [-Werror,-Wunused-parameter]
      void operator()(const nd_item<Dims> &Arg) {
                                           ^
1 error generated.

Could you fix this issue, please? See full log here: https://github.com/intel/llvm/runs/5493988722?check_suite_focus=true

Sure! #5779

Interesting, how the pre-commit checks have passed (or compilation options have changed meanwhile this has been reviewed?)

@bader
Copy link
Contributor

bader commented Mar 10, 2022

Post-commit has wider coverage. Thanks for fixing it!

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.

5 participants