Skip to content

[SYCL] Indicate lack of direct OpenCL interop when not using OpenCL BE. #1242

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 2 commits into from
Mar 13, 2020

Conversation

rbegam
Copy link
Contributor

@rbegam rbegam commented Mar 4, 2020

Signed-off-by: Sergey V Maslov [email protected]

Co-Authored-By: Rehana Begam [email protected]
Alexey Bader [email protected]

@rbegam
Copy link
Contributor Author

rbegam commented Mar 4, 2020

please review this @bjoernknafla

@bader bader self-assigned this Mar 4, 2020
@@ -1,3 +1,5 @@
// REQUIRES: 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 assume it means that this test is supposed to be skipped if there is no OpenCL support in the system.
If so, the code which detects presence of OpenCL looks strange:

# PI API either supports OpenCL or CUDA.
opencl = False
if not cuda:
    opencl = True
    config.available_features.add('opencl')

Copy link
Contributor

Choose a reason for hiding this comment

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

The current test idea is to either run testing for OpenCL xor CUDA.

(My understanding is though that some tests do not go through the SYCL default selector and therefore won't react to the env var - this adds some nondeterminism to which backend they choose).

The selection happens as follows:

  • If the check-sycl target is called, then we want to test OpenCL.
  • If the check-sycl-cuda target is called, then we want to test CUDA.
  • By hand this would either be:
    ** ./bin/llvm-lit --param SYCL_BE=PI_OPENCL ./tools/sycl/test or
    ** ./bin/llvm-lit --param SYCL_BE=PI_CUDA ./tools/sycl/test

The Python script for the LIT SYCL tests uses the SYCL_BE environment variable to pass a backend parameter to the get_device_count_by_type tool which only reports the available devices belonging to the parameter. It won't report CUDA devices when looking for OpenCL and vice versa.

Therefore, we either set the cuda xor the opencl feature but not both together.

However, it is always possible to explicitly query for all devices of all backends by not using the default device selector.

Copy link
Contributor

@bader bader Mar 5, 2020

Choose a reason for hiding this comment

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

I don't have neither OpenCL nor CUDA on my machine. What will happen to my check-sycl?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, I expect my tests to run on the host device only, but I'm not sure that tests which explicitly requested OpenCL will be disabled.

Copy link
Contributor

@bjoernknafla bjoernknafla Mar 5, 2020

Choose a reason for hiding this comment

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

Good question. I am not sure how to solve this cleanly right now, e.g., we would want to say that no backend is under test (to express that we test HOST)?

What will happen at the moment is:

  • OpenCL testing is activated.
  • No devices are found by the get-device-count-by-type tool which limits the RUN lines - so many test might skip while some fail.
  • Tests themselves still find all available devices at runtime.
  • Some tests explicitly check that they are not on host before calling into OpenCL.

If I run ninja check-sycl on the tip of sycl on a machine without OpenCL but with CUDA I get the following:

Testing Time: 158.27s
********************
Failing Tests (5):
    SYCL :: kernel_from_file/hw.cpp   <- unexpected interaction with CUDA
    SYCL :: scheduler/DataMovement.cpp   <- unexpected interaction with CUDA
    SYCL :: scheduler/MultipleDevices.cpp   <- unexpected interaction with CUDA
    SYCL :: separate-compile/test.cpp    <- unexpected interaction with CUDA

  Expected Passes    : 201
  Unsupported Tests  : 17
  Unexpected Failures: 5

On a machine without OpenCL and when not building the CUDA backend no failures happen.

Something to look into though not in this PR I recon.

Copy link
Contributor

Choose a reason for hiding this comment

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

NOTE: this file already has // REQUIRES: opencl at line 7.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bjoernknafla, I'm okay to resolve this separately. I need to go deeper into LIT config file to understand what is the best way to handle it.

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 bad, I missed the // REQUIRES: opencl at line 7. Let me check if I've missed any more.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's the only case.

Copy link
Contributor

@bjoernknafla bjoernknafla left a comment

Choose a reason for hiding this comment

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

I am not sure that the REQUIRES: opencl in sycl/test/basic_tests/buffer/buffer.cpp is required?

bjoernknafla
bjoernknafla previously approved these changes Mar 5, 2020
@@ -1,3 +1,5 @@
// REQUIRES: opencl

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove lines 9 and 10?

// TODO: Image support in CUDA backend
// XFAIL: cuda

Copy link
Contributor

Choose a reason for hiding this comment

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

It would not hurt though might be better as an extra PR to not block this one that re-enables LIT testing with CUDA?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay to resolve this comment in a separate pull request.
@bjoernknafla, will do this?
We need to clean-up following files from this PR:

basic_tests/buffer/buffer.cpp
basic_tests/sampler/sampler.cpp
fpga_tests/fpga_queue.cpp
ordered_queue/ordered_buffs.cpp
ordered_queue/ordered_dmemll.cpp
sub_group/common_ocl.cpp

I think all these files should have something like:

// REQUIRES: opencl
// UNSUPPORTED: cuda

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly @bjoernknafla mentioned that XFAIL: cuda was there to indicate that the test fails for CUDA and needs to be fixed. Have all the TODOs been resolved for ^ tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

These are requiring OpenCL, so I assume that none of them can be "fixed on CUDA". Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

sampler.cpp should have a UNSUPPORTED: cuda on it.
If the others already have REQUIRES: opencl nothing else should be required. However, I will look over this in an upcoming PR, so we could get LIT fixes of this PR in.

@bader
Copy link
Contributor

bader commented Mar 6, 2020

@rbegam, please, revert opencl-interop.cpp changes.
I have no comments other than the future refactorings we discussed in the comments.

@rbegam rbegam force-pushed the private/rbegam/sycl-interop branch from a1d7de1 to 051f200 Compare March 6, 2020 18:48
@rbegam
Copy link
Contributor Author

rbegam commented Mar 10, 2020

@bader done. please review

@rbegam
Copy link
Contributor Author

rbegam commented Mar 11, 2020

hi @bader could you please review? thanks.

@bader bader added cuda CUDA back-end and removed cuda CUDA back-end labels Mar 12, 2020
@bader bader merged commit 0caff4d into intel:sycl Mar 13, 2020
@rbegam rbegam deleted the private/rbegam/sycl-interop branch March 13, 2020 18:06
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.

3 participants