Skip to content

[CUDA][HIP] get_native() API doesn't work for device #6635

@densamoilov

Description

@densamoilov

get_native() doesn't work for device when CUDA or HIP backend is used.

Reproducer:

#include <sycl/sycl.hpp>

int main() {
    auto dev = sycl::device(sycl::gpu_selector{});
    auto ctx = sycl::context(dev);

    auto cuda_ctx = sycl::get_native<sycl::backend::ext_oneapi_cuda>(ctx);
    auto cuda_dev = sycl::get_native<sycl::backend::ext_oneapi_cuda>(dev);
    return 0;
}

Error message:

In file included from /buildspace/dpcpp/llvm/build/install/bin/../include/sycl/sycl.hpp:16:
/buildspace/dpcpp/llvm/build/install/bin/../include/sycl/backend.hpp:128:10: error: reinterpret_cast from 'pi_native_handle' (aka 'unsigned long') to 'backend_return_t<(backend)'\x03', device>' (aka 'int') is not allowed
  return reinterpret_cast<backend_return_t<BackendName, SyclObjectT>>(
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.cpp:8:31: note: in instantiation of function template specialization 'sycl::get_native<sycl::backend::ext_oneapi_cuda, sycl::device>' requested here
    auto cuda_dev = sycl::get_native<sycl::backend::ext_oneapi_cuda>(dev);
                              ^
1 error generated.

I tried DPC++ daily 2022-08-22 and oneAPI DPC++ Compiler 2022-06, the result is same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerCompiler related issuehipIssues related to execution on HIP backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions