-
Notifications
You must be signed in to change notification settings - Fork 796
Closed
Labels
bugSomething isn't workingSomething isn't workingcudaCUDA back-endCUDA back-endhipIssues related to execution on HIP backend.Issues related to execution on HIP backend.
Description
Describe the bug
item.get_id() and id.get(0) always return 0 on the GPU if the program is compiled with -fno-sycl-libspirv
To Reproduce
Sample code: From ENCCS: Hello, SYCL!:
#include <iostream>
#include <sycl/sycl.hpp>
int main() {
const std::string secret{"Ifmmp-!xpsme\"\012J(n!tpssz-!Ebwf/!"
"J(n!bgsbje!J!dbo(u!ep!uibu/!.!IBM\01"};
const auto sz = secret.size();
queue Q;
std::cout << "Running on: " << Q.get_device().get_info<info::device::name>()
<< std::endl;
char *result = malloc_shared<char>(sz, Q);
std::memcpy(result, secret.data(), sz);
// It does not matter whether I use tid.get_id(), tid, or sycl::id in the kernel
Q.parallel_for(range<1>{sz}, [=](item<1> tid) { result[tid.get_id()] -= 1; }).wait();
std::cout << result << "\n";
free(result, Q);
return 0;
}
The code is compiled with the command
clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-libspirv hello.cpp -o hello
The output on my machine is
Running on: NVIDIA Quadro RTX 6000
Hfmmp-!xpsme"
J(n!tpssz-!Ebwf/!J(n!bgsbje!J!dbo(u!ep!uibu/!.!IBM
but should be
Running on: NVIDIA Quadro RTX 6000
Hello, world! I'm sorry, Dave. I'm afraid I can't do that. - HAL
When I compile the code above without the flag -fno-sycl-libspirv
, everything works fine. And I'm getting the expected output.
Environment (please complete the following information):
- OS: Ubuntu 20.04
- NVIDIA GPU
- Clang compiled from sycl branch
- CUDA 11.3
** Additional information **
cuda-gdb
shows that there are, in fact, 65 threads created on the device:
(cuda-gdb) info cuda threads
BlockIdx ThreadIdx To BlockIdx ThreadIdx Count Virtual PC Filename Line
Kernel 0
* (0,0,0) (0,0,0) (0,0,0) (64,0,0) 65 0x0000000000aa2050 sycl_test.cpp 22
And printing tid
shows the same object (?) on two different threads:
(cuda-gdb) cuda thread 30
[Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (30,0,0), device 0, sm 0, warp 0, lane 30]
22 result[tid.get_id()] -= 1;
(cuda-gdb) p tid
$1 = {MImpl = {MExtent = {sycl::_V1::detail::array<1> = {common_array = {65}}}, MIndex = {sycl::_V1::detail::array<1> = {common_array = {0}}}, MOffset = {
sycl::_V1::detail::array<1> = {common_array = {0}}}}}
(cuda-gdb) cuda thread 0
[Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (0,0,0), device 0, sm 0, warp 0, lane 0]
22 result[tid.get_id()] -= 1;
(cuda-gdb) p tid
$2 = {MImpl = {MExtent = {sycl::_V1::detail::array<1> = {common_array = {65}}}, MIndex = {sycl::_V1::detail::array<1> = {common_array = {0}}}, MOffset = {
sycl::_V1::detail::array<1> = {common_array = {0}}}}}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcudaCUDA back-endCUDA back-endhipIssues related to execution on HIP backend.Issues related to execution on HIP backend.