8000 Adding a test case for reqd_work_group_size using L0 backend. by clevels · Pull Request #2005 · intel/llvm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding a test case for reqd_work_group_size using L0 backend. #2005

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 14 commits into from
Jul 4, 2020

Conversation

clevels
Copy link
Contributor
@clevels clevels commented Jun 29, 2020

Resolved issues test case discovered.

Signed-off-by: Cory Levels cory.levels@intel.com

Resolved issues test case discovered.

Signed-off-by: Cory Levels <cory.levels@intel.com>
@clevels clevels requested review from smaslov-intel and a team as code owners June 29, 2020 20:01
@@ -21,6 +21,35 @@ namespace detail {

namespace enqueue_kernel_launch {

bool L0HandleInvalidWorkGroupSize(const device_impl &DeviceImpl,
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be no L0-specifc in this checking, it should be covered by PI API. Can you combine this with oclHandleInvalidWorkGroupSize into just HandleInvalidWorkGroupSize?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Sergey, could you please see this section here https://github.com/intel/llvm/pull/1998/files#diff-5b57d29ae1eb53bd221ca97692974846R48? I think that is valid for L0 and should be added here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @smaslov-intel , If you look at the current function L0HandleInvalidWorkGroupSize the code is doing the same thing as a couple parts of oclHandleInvalidWorkGroupSize. So agreed they should be combined. I spoke to Rehana offline and we discussed renaming oclHandleInvalidWorkGroupSize to the generic HandleInvalidWorkGroupSize and just adding conditional statements if (PlatformName.find("OpenCL") != std::string::npos) around all the checks that are openCL specific. Would this be the best approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, yes. I'd still want to see if any backend specifics can be hidden under PI, so that those specifics are implemented in the relevant plugins not in in SYCL RT.

Copy link
Contributor
@rbegam rbegam left a comment

Choose a reason for hiding this comment

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

LGTM

smaslov-intel
smaslov-intel previously approved these changes Jul 2, 2020
Copy link
Contributor
@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

LGTM

rbegam
rbegam previously approved these changes Jul 2, 2020
Copy link
Contributor
@rbegam rbegam left a comment

Choose a reason for hiding this comment

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

LGTM

@clevels clevels dismissed stale reviews from rbegam and smaslov-intel via 14673ff July 2, 2020 18:39
smaslov-intel
smaslov-intel previously approved these changes Jul 2, 2020
rbegam
rbegam previously approved these changes Jul 2, 2020

size_t VerSize = 0;
Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION, 0,
nullptr, &VerSize);
assert(VerSize >= 10 &&
"Unexpected device version string"); // strlen("OpenCL X.Y")
if (Platform.get_backend() == cl::sycl::backend::opencl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I expected SYCL runtime to performs back-end agnostic checks only, so parsing OpenCL version in this file doesn't seem right to me.
Shouldn't we sink most of these error checks into corresponding plug-ins?

throw sycl::nd_range_error(
"Total number of work-items in a work-group cannot exceed "
"info::kernel_work_group::work_group_size which is equal to " +
std::to_string(KernelWGSize) + " for this kernel",
Copy link
Contributor

Choose a reason for hiding this comment

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

"for this kernel" doesn't help if I have more than one. I suggest adding a kernel name to the message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note, however, that:

  • Kernels do not always have a name that is meaningful to the user since the KernelName template parameter is optional as of SYCL 2020 provisional.

  • The exception is thrown synchronously when submitting a kernel, so the problematic kernel should be clear if the application uses try/catch around the code that submits the kernel.

Adding the name of the kernel to the exception string does seem reasonable in the case where the user specified a name. If we decide to do that, we should do it uniformly for all the exceptions diagnosed in this function, not just for this one exception.

@@ -0,0 +1,109 @@
// XFAIL: cuda || opencl
Copy link
Contributor

Choose a reason for hiding this comment

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

There were changes in opencl specific code, so I suggest validate opencl back-end as well.

I think it better to use unittest framework with mocking API.

Co-authored-by: Alexey Bader <alexey.bader@intel.com>
@clevels clevels dismissed stale reviews from rbegam and smaslov-intel via fbb0655 July 3, 2020 14:09
clevels and others added 7 commits July 3, 2020 09:10
Co-authored-by: Alexey Bader <alexey.bader@intel.com>
Co-authored-by: Alexey Bader <alexey.bader@intel.com>
Co-authored-by: Alexey Bader <alexey.bader@intel.com>
Co-authored-by: Alexey Bader <alexey.bader@intel.com>
Co-authored-by: smaslov-intel <48694368+smaslov-intel@users.noreply.github.com>
bader
bader previously approved these changes Jul 3, 2020
@bader
Copy link
Contributor
bader commented Jul 3, 2020

@clevels and I agreed to address the rest of the comments in follow-up PRs.

@bader bader merged commit 03ef819 into intel:sycl Jul 4, 2020
return 1;
}

// Positive test-cases that should pass on any underlying OpenCL runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

This test case is not specific to OpenCL, so I would change this comment to something like: "... that should pass on any backend".

if (Platform.get_backend() == cl::sycl::backend::opencl) {
assert(VerSize >= 10 &&
"Unexpected device version string"); // strlen("OpenCL X.Y")
}
string_class VerStr(VerSize, '\0');
Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION,
VerSize, &VerStr.front(), nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment applies to the entire block of code:

  size_t VerSize = 0;
  Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION, 0,
                                          nullptr, &VerSize);
  if (Platform.get_backend() == cl::sycl::backend::opencl) {
    assert(VerSize >= 10 &&
           "Unexpected device version string"); // strlen("OpenCL X.Y")
  }
  string_class VerStr(VerSize, '\0');
  Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION,
                                          VerSize, &VerStr.front(), nullptr);
  const char *Ver = &VerStr[7]; // strlen("OpenCL ")

There are two problems here:

  1. The Ver pointer could point to uninitialized memory when the backend is not OpenCL.
  2. The name of the Ver variable should indicate that it is specific to OpenCL.

It would also be nice to include a comment, so readers understand why you are getting the version only for OpenCL.
I'd suggest rewriting the code to follow this form:

// Some of the error handling below is special for particular OpenCL versions.
// If this is an OpenCL backend, get the version.
const char *OpenClVer = nullptr;
string_class OpenClVerStr;
if (Platform.get_backend() == cl::sycl::backend::opencl) {
  size_t OclVerSize = 0;
  Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION, 0,
                                          nullptr, &OclVerSize);
  assert(VerSize >= 10 &&
         "Unexpected device version string"); // strlen("OpenCL X.Y")
  OpenClVerStr.assign(OclVerSize, '\0');
  Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_VERSION,
                                          OclVerSize, &OpenClVerStr.front(), nullptr);
  OpenClVer = &OpenClVerStr[7]; // strlen("OpenCL ")
}

"OpenCL 1.x and 2.0 requires to pass local size argument even if "
"required work-group size was specified in the program source",
PI_INVALID_WORK_GROUP_SIZE);
}
// Any OpenCL version:
Copy link
Contributor

Choose a reason for hiding this comment

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

This error check is not specific to OpenCL, so remove this part of the comment.

std::to_string(MaxWGSize),
PI_INVALID_WORK_GROUP_SIZE);
} else {
// RELEVENT // OpenCL 2.x:
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you added the word "RELEVANT" to this comment. Was that a note to yourself indicating that this arm of the if statement was relevant to L0 (non-OpenCL backends)? If so, I think you should either change the code like this:

if (Platform.get_backend() == cl::sycl::backend::opencl && OpenClVer[0] == '1') {
  // Do the first check
}
else {
  // Do the second check
}

Or, if you are planning to do this as part of a subsequent PR, add a more informative TODO comment indicating what needs to be done.

}
}
throw sycl::nd_range_error(
"Non-uniform work-groups are not supported by the target device",
PI_INVALID_WORK_GROUP_SIZE);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the checks above are done only for the OpenCL backend. I presume something is needed for the other backends too? If so, I'd recommend at least adding a TODO comment to that effect:

}
else {
    // TODO: Similar checks should be done for the non-OpenCL backends.
}

Here, the else should match the if (Platform.get_backend() == cl::sycl::backend::opencl) on line 143.

jsji pushed a commit that referenced this pull request May 16, 2023
Currently only to DebugInfo/X86

Currently failing tests can be noticed by RUNx line

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@772c7be
jsji pushed a commit that referenced this pull request May 16, 2023
Currently only to DebugInfo/X86

Currently failing tests can be noticed by RUNx line

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@772c7be
jsji pushed a commit to sys-ce-bb/llvm that referenced this pull reques CD03 t May 16, 2023
Currently only to DebugInfo/X86

Currently failing tests can be noticed by RUNx line

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@772c7be
@jsji jsji mentioned this pull request May 16, 2023
jsji pushed a commit that referenced this pull request May 16, 2023
Currently only to DebugInfo/X86

Currently failing tests can be noticed by RUNx line

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@772c7be
This was referenced May 16, 2023
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
0