Skip to content

[SYCL] Initial commit of interop example #2

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 4 commits into from
May 11, 2020
Merged

[SYCL] Initial commit of interop example #2

merged 4 commits into from
May 11, 2020

Conversation

Ruyk
Copy link
Contributor

@Ruyk Ruyk commented May 7, 2020

Example of using interop task to use CUBLAS from SYCL

const size_t WIDTH = 1024;
const size_t HEIGHT = 1024;
const float ALPHA = 1.0f;
const float BETA = 0.0f;
Copy link

Choose a reason for hiding this comment

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

These can be constexpr

h.interop_task([=](sycl::interop_handler ih) {
cublasSetStream(handle, ih.get_queue<backend::cuda>());

float *cuA = reinterpret_cast<float *>(ih.get_mem<backend::cuda>(d_A));
Copy link

Choose a reason for hiding this comment

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

What's the native handle for CUDA memory? Could you use a static_cast instead? Also you can use auto instead of float* since you already specify the exact type with the cast.

Copy link
Contributor Author

@Ruyk Ruyk May 8, 2020

Choose a reason for hiding this comment

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

CUdeviceptr is the native type but is not used in CUDA Runtime API, just using the pointer is enough. Cannot static cast because it converts a number into a pointer

const size_t WIDTH = 1024;
const size_t HEIGHT = 1024;
const float ALPHA = 1.0f;
const float BETA = 0.0f;
Copy link

Choose a reason for hiding this comment

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

These can be constexpr

@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
Copy link

Choose a reason for hiding this comment

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

Why is CMake 3.17 such a strong requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The

find_package(CUDAToolkit)

used below simplifies the setting up of the project, but is only available on latest cmake.

@Ruyk Ruyk merged commit c278fcc into master May 11, 2020
@Ruyk Ruyk deleted the cuda_interop branch May 11, 2020 14:07
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